Note that there are some explanatory texts on larger screens.

plurals
  1. POImporting Pages with Python, PyQt, Qt Designer, & QStackedWidget
    primarykey
    data
    text
    <p>I'm trying to import a page using PyQt and add it to a QStackedWidget created using Qt Designer. I'd like to not touch the compiled page code nor the compiled MainWindow code. I can show the MainWindow fine, but I can't seem to import the page and add it my QStackedWidget.</p> <p>Here is what my MainWindow and page compiled code looks like:</p> <p>My <code>mainWindow.py</code></p> <pre class="lang-py prettyprint-override"><code> from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) ... </code></pre> <p>My <code>appInfoPage.py</code></p> <pre class="lang-py prettyprint-override"><code> from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class Ui_appInfoPage(object): def setupUi(self, appInfoPage): appInfoPage.setObjectName(_fromUtf8("appInfoPage")) ... </code></pre> <p>My main.py</p> <pre class="lang-py prettyprint-override"><code> from PyQt4.QtGui import * from PyQt4.QtCore import * from mainWindow import Ui_MainWindow from appInfoPage import Ui_appInfoPage class main(QMainWindow, Ui_MainWindow): def __init__(self): super(QMainWindow, self).__init__() self.setupUi(self) self.appInfoPage = Ui_appInfoPage() self.appInfoPage.setupUi(self.appInfoPage) self.stackedWidget.addWidget(self.appInfoPage) self.stackedWidget.setCurrentWidget(self.appInfoPage) if __name__ == '__main__': application = QApplication(sys.argv) window = main() window.show() sys.exit(application.exec_()) </code></pre> <p>The current code gives me a <code>AttributeError: 'Ui_appInfopage' object has no attributes 'setObjectName'</code> error and if I put <code>self.appInfoPage.setupUi(self)</code> instead, the page overlaps the MainWindow.</p> <p>Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload