0

I am newly using PyQt4 on Ubuntu. My problem is that pyuic4 generates code that subclasses object rather than the appropriate widget class, which in this case should be QDialog.

I can import PyQt4.Qt in the python interpreter without error, and I can run the .ui python script in code that dynamically loads it using uic.loadUiType("filename.ui").

I suspect I did something wrong when installing Qt, sip, and PyQt4, but I've gone over the various instructions and can't see where I might have gone wrong. Lots of googling hasn't turned up anyone with a similar problem, so I'm asking for help.

Has anyone seen this before, or know what's going on? I welcome suggestions as to how fix this.

KJR
  • 3
  • 2

1 Answers1

1

This is not a problem. It is supposed to be like that. You need to make another class and subclass from your generated class AND from QDialog. This is your generated class:

class Ui_Class1(object):
    ...

This is the second class:

class Class1(QtGui.QDialog, Ui_Class1):
    ...

Now you can make changes to Class1 and use it. Important: Since Ui_Class1(object) is automatically generated you should not make any changes to this class. Make all your changes to Class1(QtGui.QDialog, Ui_Class1).

jonie83
  • 1,136
  • 2
  • 17
  • 28
  • Thank you for your answer. I'm glad my configuration is correct. I was working through a tutorial by Jonathan Gardner, https://wiki.python.org/moin/JonathanGardnerPyQtTutorial, which apparently is out of date. I guess object used to have different behavior which enabled his code to work. It doesn't work any longer. – KJR Sep 04 '14 at 17:40