QDialog not reappearing after hiding parent window on Ubuntu



  • I have a program that hides in a system tray area. It uses few dialogs for interactions with user. The problem is when i hide my app to tray with some dialogs still open. After restoring the windows to normal stated, dialogs disappear. The problem occurs on Ubuntu 17.10 with Qt 5.9.2, but I suppose that other Linux distributions may have this problem as well. I tested it with Plasma, GNOME and Unity. Same result. Windows version of my program works correctly, windows are hidden and restored as expected. Simple code can present the issue:

    #include <QtWidgets>
    #include <QtGui>
     
    int main(int argc, char *argv[]) {
        QApplication a(argc, argv);
        QWidget w;
        QDialog d(&w);
        QTimer::singleShot(1000, [&] { w.show(); });
        QTimer::singleShot(2000, [&] { d.show(); });
        QTimer::singleShot(3000, [&] { w.showMinimized(); });
        QTimer::singleShot(4000, [&] { w.hide(); });
        QTimer::singleShot(5000, [&] { w.show(); });
        QTimer::singleShot(6000, [&] { w.showNormal(); });
        a.exec();
    }
    

    After w.hide() dialog won't show again. Any additional calls of dialog methods like show(), showNormal() do nothing. Any ideas? Is this a bug, or is there something wrong with my code?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What do you mean by disappear ?
    Do they get hidden by the other window or just invisible ?



  • Invisible. I can't manage to get the dialog shown with parent window.
    Before: QWidget and QDialog on top of it.
    After: QWidget only. QDialog disappeared.


  • Lifetime Qt Champion

    Are you using your distribution provided Qt ?



  • I use Qt installed with MaintenanceTool. I asked this question on other forum and one person has confirmed having same issue on Ubuntu 18.04, so I think that this problem is not only related to my configuration.


  • Moderators

    @artudi54 Is the QDialog modal using QDialog::exec() or is it shown with QDialog::show()?

    Edit: nevermind I see the code above, lol.. I'll test for you on my linux real quick.


  • Moderators

    @artudi54 Tested with gnome on arch and it does the same thing. I'd say this is a bug since d.show() never pulls the window back up.

    I would file the bug with Qt.

    To work around it I just made sure to call d.hide() before hiding the main window. Then after w.show() just call d.show() again.