I'm making a GUI using Qt-Designer and Pyqt5 in python 3.6.3.
The GUI has a QStackedWidget with 2 pages. Each page has a arrow above so the user can switch between them(as showen in Qt-Designer (see pciture below)).
The problem is, when I convert the ui to py using pyuic5and then run the py code the arrows to switch the pages of the QStackedWidget are disappeared.
How the arrows can be showen while running the py code?
code:
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(314, 216)
self.stackedWidget = QtWidgets.QStackedWidget(Dialog)
self.stackedWidget.setGeometry(QtCore.QRect(40, 40, 211, 101))
self.stackedWidget.setLayoutDirection(QtCore.Qt.LeftToRight)
self.stackedWidget.setStyleSheet("selection-background-color: rgb(255, 255, 127);\n"
"background-color: rgb(154, 154, 154);\n"
"border-color: rgb(255, 0, 0);\n"
"selection-color: rgb(85, 255, 0);")
self.stackedWidget.setFrameShape(QtWidgets.QFrame.Box)
self.stackedWidget.setFrameShadow(QtWidgets.QFrame.Plain)
self.stackedWidget.setLineWidth(1)
self.stackedWidget.setMidLineWidth(2)
self.stackedWidget.setObjectName("stackedWidget")
self.page = QtWidgets.QWidget()
self.page.setObjectName("page")
self.lineEdit_2 = QtWidgets.QLineEdit(self.page)
self.lineEdit_2.setGeometry(QtCore.QRect(80, 40, 113, 25))
self.lineEdit_2.setMinimumSize(QtCore.QSize(113, 0))
self.lineEdit_2.setStyleSheet("background-color: rgb(255, 255, 255);")
self.lineEdit_2.setObjectName("lineEdit_2")
self.label = QtWidgets.QLabel(self.page)
self.label.setGeometry(QtCore.QRect(10, 40, 68, 19))
self.label.setMinimumSize(QtCore.QSize(68, 0))
self.label.setObjectName("label")
self.stackedWidget.addWidget(self.page)
self.page_2 = QtWidgets.QWidget()
self.page_2.setObjectName("page_2")
self.lineEdit = QtWidgets.QLineEdit(self.page_2)
self.lineEdit.setGeometry(QtCore.QRect(80, 40, 113, 25))
self.lineEdit.setMinimumSize(QtCore.QSize(113, 0))
self.lineEdit.setStyleSheet("background-color: rgb(255, 255, 0);\n"
"border-color: rgb(0, 0, 255);")
self.lineEdit.setObjectName("lineEdit")
self.label_2 = QtWidgets.QLabel(self.page_2)
self.label_2.setGeometry(QtCore.QRect(10, 40, 68, 19))
self.label_2.setMinimumSize(QtCore.QSize(68, 0))
self.label_2.setObjectName("label_2")
self.stackedWidget.addWidget(self.page_2)
self.retranslateUi(Dialog)
self.stackedWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "I/P1 ="))
self.label_2.setText(_translate("Dialog", "I/P2 ="))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
the right view of QStackedWidget
