I hope I have a simple question here. I have created a very large GUI with QT Designer and a subwindow for the MDI area. I have used pyuic5 to convert it from a .ui
file to a .py
file. I have written a function to open that subwindow when a button is pressed. The first time I push the button it works fine. The problem I'm having is the second time the button is pushed it just displays a blank subwindow within the MDI area. How do I get it to display correctly every time the button is pressed. I will attach the code for how I launch the subwindow below. Any advice would be very appreciated. Thank you for your time and your help
Code that is called when button is clicked
def windowaction(self):
sub = QtWidgets.QMdiSubWindow()
sub.setWidget(self.Load_Input)
sub.setObjectName("Load_Input_window")
sub.setWindowTitle("Load Input")
self.mdiArea.addSubWindow(sub)
sub.show()
The problem arises from adding the same widget object to different QMdiSubWindow
, you must create a new object and add it to the new QMdiSubWindow
.
def windowaction(self):
sub = QtWidgets.QMdiSubWindow()
Load_Input = LoadInput()
sub.setWidget(Load_Input)
sub.setObjectName("Load_Input_window")
sub.setWindowTitle("Load Input")
self.mdiArea.addSubWindow(sub)
sub.show()