{"id":169,"date":"2010-01-18T14:29:00","date_gmt":"2010-01-18T14:29:00","guid":{"rendered":"https:\/\/www.root42.de\/blog\/?p=169"},"modified":"2010-01-18T14:29:00","modified_gmt":"2010-01-18T14:29:00","slug":"pyqt-dynamic-uic-example","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=169","title":{"rendered":"PyQt dynamic uic example"},"content":{"rendered":"<p>Here is a minimal example for <a href=\"http:\/\/www.riverbankcomputing.co.uk\/software\/pyqt\/intro\">PyQt4<\/a>, to set up a main window and connect a simple action to some slot. The documentation on doing this is sparse to say the least. So I hope this is helpful for anyone trying something similar. I assume that you have created a ui_MainWindow.ui file with Qt Designer, which contains a form derived from QMainWindow.<\/p>\n<pre><br \/>import sys<br \/>from PyQt4 import QtCore, QtGui, uic<br \/><br \/>class MyMainWindow(QtGui.QMainWindow):<br \/><br \/>   def __init__(self):<br \/>      QtGui.QMainWindow.__init__(self)<br \/>      self.ui = uic.loadUi(\"ui_MainWindow.ui\", self)<br \/>      self.connect(self.ui.actionOpen, QtCore.SIGNAL('triggered()'), self, QtCore.SLOT('open()'))<br \/>   <br \/>   @QtCore.pyqtSlot()<br \/>   def open(self):<br \/>      fileDialog = QtGui.QFileDialog(self, \"Open file\")<br \/>      fileDialog.show()<br \/><br \/>app = QtGui.QApplication(sys.argv)<br \/>mainWindow = MyMainWindow()<br \/>mainWindow.show()<br \/>sys.exit(app.exec_())<br \/><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is a minimal example for PyQt4, to set up a main window and connect a simple action to some slot. The documentation on doing this is sparse to say the least. So I hope this is helpful for anyone trying something similar. I assume that you have created a ui_MainWindow.ui file with Qt Designer, &hellip; <a href=\"https:\/\/www.root42.de\/blog\/?p=169\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PyQt dynamic uic example&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,15,67],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/169"}],"collection":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=169"}],"version-history":[{"count":0,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/169\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}