Reputation: 11
I want to display a window when I press a button. When I click the button the parent window remains there and new window is displayed for a fraction of a second and disappears. How can I display the new window over the previous window that contains the button.
Upvotes: 1
Views: 110
Reputation: 120578
It sounds like you're not keeping a reference to the child window, and so it's getting garbage-collected immediately after it's shown.
Your button handler probably looks something like this:
def handleOpenWindow(self):
window = QMainWindow()
window.show()
Instead, you need to do this:
self.window = QtGui.QMainWindow()
self.window.show()
Or this:
window = QtGui.QMainWindow(self)
window.show()
Upvotes: 2