Subclassed QDialog, exec() calls after the first one, don't raise the dialog!



  • I have a working custom QDialog in PyQt5, python 3.5.2. There is a main window, that invokes the dialogs. The first invokation (using exec_()) succeeds. But calling exec_() again fails to put the dialog on top. It's present in the task bar only, so I have to go and click on it. But I need it to raise to the top every time!

    Is this because I'm not using the parent parameter of the QDialog constructor? I'll test that out...



  • This fixes it:

    self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)



  • @enjoysmath
    I wouldn't expect to need to use that, and would have thought it could lead to other problems. A dialog should be on top anyway. Did you try just passing the main window as the parent?


Log in to reply