[PyKDE] Trying to launch a gui made with QTDesigner

Tony Cappellini cappy2112 at gmail.com
Sun Jan 21 04:53:53 GMT 2007


I've made a simple gui that has just a few widgets on it using QTDesigner
I was able to preview the code in QtDesigner

I'm trying to launch it now from a command line script, using this example
on Riverbank's page

http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#using-the-generated-code
The first example shows the direct approach where we simply create a simple
application to create the dialog:

import sys
from PyQt4 import QtGui
from ui_imagedialog import Ui_ImageDialog

app = QtGui.QApplication(sys.argv)
window = QtGui.QDialog()
ui = Ui_ImageDialog()
ui.setupUi(window)

window.show()
sys.exit(app.exec_())


I've substituted Ui_ImageDialog with the class generated by QTDesigner

from PyQt4 import QtCore, QtGui
from mainwindow import Ui_MainWindow

class MainWindow(QtGui.QDialog):
    def __init__(self):
        app = QtGui.QApplication(sys.argv)
        window = QtGui.QDialog()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(window)
        window.show()
        sys.exit(app.exec_())

mainwindow = MainWindow()


however, I get this error, which I dont understand.

Traceback (most recent call last):
  File "maingui.py", line 16, in ?
    mainwindow = MainWindow()
  File "maingui.py", line 12, in __init__
    self.ui.setupUi(window)
  File "C:\Code\mainwindow.pyw", line 227, in setupUi
    MainWindow.setCentralWidget(self.centralwidget)
AttributeError: setCentralWidget


Would someone explain what I'm doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070121/c9dc91e1/attachment.html


More information about the PyQt mailing list