[PyQt] Using PyQt within an application

David Boddie david at boddie.org.uk
Sun Aug 17 16:51:15 BST 2008


On Sun Aug 17 15:14:32 BST 2008, andYpsilon wrote:

> Theres nothing special to the code I am using. It's what is coming out of
> Designer, modified for having the functionality I need.
>
> starter is the function I call to start my dialog:
>
> ...
>
> class MeinDialog(QtGui.QDialog, Dlg):
>     def __init__(self):
>         QtGui.QDialog.__init__(self)
>         self.setupUi(self)
>
> def starter():
>     app = QtGui.QApplication(sys.argv)
>     dialog = MeinDialog()
>     dialog.setModal(False)
>     dialog.show()
>     sys.exit(app.exec_())

sys.exit() will cause Python to exit. If this isn't what you want, just
call app.exec_() and Python will continue running after the PyQt stuff
has finished.

> ...
>
> in the interface class this is the SIGNAL I am using to quit with a button:
>
> ...
>         self.retranslateUi(Dialog)
>
> QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL("clicked()"),self.clos
>e) QtCore.QMetaObject.connectSlotsByName(Dialog)

Using self.close is fine here. I was a bit worried that you were calling
qApp.quit() or something.

David


More information about the PyQt mailing list