Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
class MainWindow(QWidget):
    def __init__(self):
        super(MainWindow, self).__init__()

        uic.loadUi("driveSelection.ui", self)
        self.setWindowTitle("Welcome Screen")
        self.setWindowIcon(QIcon("Picture.png"))
        self.backButton.clicked.connect(self.gotoScreen)

    def gotoScreen(self):
        pathselection1 = pathSelection1()
        widget.addWidget(pathselection1)
        widget.setCurrentIndex(widget.currentIndex() + 1)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    widget = QtWidgets.QStackedWidget()
    mainwindow = MainWindow()
    widget.addWidget(mainwindow)
    widget.setFixedHeight(300)
    widget.setFixedWidth(500)
    widget.show()
    sys.exit(app.exec_())


What I have tried:

In this code, I am trying to add a title, icon, and some other features in a window but when I run the code, the window appears but the features in a window do not show up. Although all the features were working fine when I used this code
if __name__ == "__main__":
     app = QApplication(sys.argv)
     window = MainWindow()
     window.show()
     sys.exit(app.exec_())

But when I changed it to make the gotoScreen function working, it didn't work except the window appearing.
Posted
Updated 25-Jan-21 18:15pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900