0
假設我有兩個來自Qt Designer的UI文件:mainform.ui存儲mdiArea和figureslist.ui存儲listView。Qt mdi應用程序與QtDesigner的custiom UI
現在我想創建一個mdi應用程序,它可以打開figureList窗口的數量。
import sys
from PyQt4 import QtGui
#from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, uic
class HelloWorldApplication(QtGui.QApplication):
def __init__(self, args):
QtGui.QApplication.__init__(self, args)
self.maindialog = MainUI(None)
class MainUI(QtGui.QMainWindow):
def __init__(self, parent):
QtGui.QMainWindow.__init__(self, parent)
self.ui = uic.loadUi("mainform.ui")
self.ui.show()
# create child and show it
child = self.createFiguresListView()
# problem here (*)
child.show()
def createFiguresListView(self):
child = FiguresListView()
self.ui.mdi.addSubWindow(child)
return child
class FiguresListView(QtGui.QWidget):
def __init__(self):
super(FiguresListView, self).__init__()
self.ui = uic.loadUi("figureslist.ui")
app = HelloWorldApplication(sys.argv)
sys.exit(app.exec_())
但不幸的是我的孩子窗口顯示了沒有figureslist.ui描述佈局崩潰,但就像MDI子,但如果我代替)標有(*)的代碼child.ui.show(它顯示實際佈局,但不像mdi孩子。
怎麼了?