我有如下代码片段:
self.model = QFileSystemModel()
self.model.setRootPath('')
self.tree = QTreeView()
self.tree.setModel(self.model)
self.tree.setAnimated(False)
self.tree.setIndentation(20)
self.tree.setSortingEnabled(True)
self.tree.setWindowTitle("Directory Viewer")
self.tree.resize(323, 300)
self.tree.show()
这将打开一个管理目录(文件)的窗口。但在我的MainApp UI(打开一个新窗口)中,我想嵌入这个外部窗口,如下所示:
^{pr2}$如何将这个窗口嵌入到我的mainappui中,作为主图形应用程序的一部分,比如小部件?在
谢谢!在
一个可能的解决方案是使用布局来定位窗口内的小部件。
QMainWindow
的情况很特殊,因为您不必建立一个布局,它有一个预定义的布局:您需要做的是创建一个中心小部件并建立布局:
相关问题 更多 >
编程相关推荐