Menu

QDialog setParent to MainWindow

Help
Oren
2015-05-05
2015-05-09
  • Oren

    Oren - 2015-05-05

    Hello,

    My C++ application has a mainw (main window) that inherits QMainWindow, and dialogs are initializing their ancestor QDialog with mainw as parent. As an expected result, they close together with the application. mainw is addObject-ed to the pythonqt environment.
    In addition, my app also has the example python interpreter, which is a parentless textedit.
    When my app closes and the interpreter is still open, all dialogs close as well (because of mainw parenthood), and the only window remaining alive is the interpreter - together with its tray bar entity.

    When I run the following code, a dialog is shown without a separate tray bar entity - as similar to other C++-created dialogs in the app.

    from PythonQt import QtGui, Qt
    dialog = QtGui.QDialog(mainw)
    dialog.setWindowFlags(Qt.Qt.Dialog)
    dialog.show()

    However, when I close the app, I would expect the pythonqt-created dialog to close as well. In effect, it stays open - but it doesn't have a tray bar entity anymore, as that belonged to the mainw that is already closed. The only tray bar entity remaining is that of the interpreter.

    Am I missing any key requirement, or is C++ parenthood on pythonqt objects not working?

    P.S.
    When the interpreter is not running anymore, but the pythonqt-created dialog is still open, and I close the app, the dialog also closes - as expected. So parenthood does work to some extent.

    Thanks,
    Oren Shatz

     

    Last edit: Oren 2015-05-05
  • Oren

    Oren - 2015-05-09

    Alright, I figured out the problem,
    once the interpreter was put in parented dialog too, everything went fine.

     

Log in to post a comment.