[PyQt] Problem with class inheriting QDialog
Mark Summerfield
list at qtrac.plus.com
Sat Nov 21 08:39:22 GMT 2009
On 2009-11-20, dizou wrote:
> Dialog.py:
>
> import sys
> from PyQt4.QtGui import QDialog
>
> def Dialog(QDialog):
I assume that's a typo above and that you've really got:
class Dialog(QDialog):
> def __init__(self, parent):
> QDialog.__init__(self, parent)
>
> MainWindow.py:
>
> from PyQt4.QtCore import SIGNAL, SLOT, QDir, QFile
> from PyQt4.QtGui import QApplication, QMainWindow, QMenu, QMessageBox, \
> QWidget, qApp, QAction, QFileDialog, QPushButton
> from Dialog import *
>
> class MainWindow(QMainWindow):
> def __init__(self):
And as David Douard mentioned, you must do
super().__init__(self) # or similar
> #stuff
> self.editButton = QPushButton(self)
> self.connect(self.editButton, SIGNAL("clicked()"),
> self.EditButtonClicked)
> def EditButtonClicked(self):
> self.dialog = Dialog(self)
> print type(self.dialog)
> self.dialog.exec_()
>
--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Programming in Python 3 (Second Edition)" - ISBN 0321680561
More information about the PyQt
mailing list