Can anyone tell me why this code is not working? The Test4 class is my converted simple UI:
import sys
import Test4
from PyQt4 import QtGui, QtCore
class UiViewer(QtGui.QApplication, Test4.Ui_Dialog):
def __init__(self, parent=None):
return super(UiViewer, self).__init__(parent)
self.setupUi(self)
def main(self):
self.show()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
uiViewer = UiViewer()
uiViewer.main()
app.exec_()
Your
UiViewerclass needs to inherit from the same class as the top-level widget in Qt Designer (presumablyQDialog, in your case, but it could also be aQMainWindowor aQWidget):And note that you must not put
returnbefore thesupercall, otherwise the__init__function will exit at that point, meaning the rest of its code won't be executed (in particular,setupUiwould not be called).