[PyQt] Loading a QMainWindow with uiloader

Angelo Compagnucci angelo.compagnucci at gmail.com
Mon May 21 10:43:14 BST 2012


Hi guys,

I have done this:

def setupUi(self, MainWindow):
        loader = QUiLoader()
        file = QFile("...")
        file.open(QFile.ReadOnly)
        centralwidget = loader.load(file, self)
        centralwidget.setWindowFlags(Qt.Widget)
        self.setCentralWidget(centralwidget)

It works, but the real centralWidget is nested into the main QMainWindow
centralWidget, so to set my own centralWidget, I have to do:

self.centralWidget().setCentralWidget(...)

There is a better way to load a QMainWindow from a ui file via QUiLoader?

Thank you!

-- 
Profile: http://it.linkedin.com/in/compagnucciangelo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120521/7e453dd2/attachment.html>


More information about the PyQt mailing list