On Sat, 20 Jan 2007 20:53:53 -0800, Tony Cappellini wrote:

> 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

[...]

> 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

setCentralWidget() is a method provided by QMainWindow and its subclasses.

> Would someone explain what I'm doing wrong?

You need to use QMainWindow as the base class instead of QDialog because the
widget you made in Qt Designer is based on QMainWindow.

David

_______________________________________________
PyKDE mailing list    [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to