So, I am pretty new on PyQt5 and I am facing the following problem:
- I have a window showing some information and buttons:
class HomeWindow(QDialog):
def __init__(self):
super(HomeWindow, self).__init__()
loadUi('homeScreen.ui', self)
self.newItemButton.clicked.connect(self.newItem)
self.flightLogButton.clicked.connect(self.flightLog)
self.maintenanceLogButton.clicked.connect(self.maintenanceLog)
def newItem(self):
newItem = NewItemWindow()
widget.addWidget(newItem)
widget.setCurrentIndex(widget.currentIndex()+1)
def flightLog(self):
flightLog = FlightLogWindow()
widget.addWidget(flightLog)
widget.setCurrentIndex(widget.currentIndex()+1)
def maintenanceLog(self):
maintenanceLog = MaintenanceLogWindow()
widget.addWidget(maintenanceLog)
widget.setCurrentIndex(widget.currentIndex()+1)
When I click on the button it will take me to the window I want, for example here newItem:
class NewItemWindow(QDialog):
def __init__(self):
super(NewItemWindow, self).__init__()
loadUi('addItem.ui', self)
self.backButton.clicked.connect(self.back)
def back(self):
widget.setCurrentIndex(widget.currentIndex()-1)
It works fine and it takes me to the window I want, when I click backButton, it takes me to the initial window. Now the problem is that if I click again in a different button, for example flighLogButton, it will take me to the window linked to the button that I first clicked, in this case newItem.
So my question is: Am I missing something here or is it not possible to work this way with PyQt5?