[PyQt] Problem with class inheriting QDialog

Phil Thompson phil at riverbankcomputing.com
Thu Nov 19 22:43:49 GMT 2009


On Thu, 19 Nov 2009 13:45:31 -0800 (PST), dizou <di_zou at yahoo.com> wrote:
> I have a class Dialog inheriting a QDialog:
> 
> def Dialog(QDialog):
> 	def __init__(self, parent):
> 		QDialog.__init__(self, parent)
> 
> I have a MainWindow class that inherits QMainWindow that creates the
Dialog
> class:
> 
> class MainWindow(QMainWindow):
>     def __init__(self):
>         #stuff
>     def MyFunction():
>         dialog = Dialog(self)
>         print type(dialog)
>         dialog.exec_()
> 
> When MyFunction is called I get this output and error:
> 
> <type 'NoneType'>
> ...
> AttributeError: 'NoneType' object has no attribute 'exec_'
> 
> I guess the QDialog isn't being initialized right? How do I fix this?

First you post a short, complete example program that demonstrates the
problem.

Then we point out the bug in your example.

Phil


More information about the PyQt mailing list