Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Unexpected behaviour when I call show() to show a closed window again



  • MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        QMainWindow *mm = new QMainWindow;
        mm->setAttribute(Qt::WA_DeleteOnClose, false);
        connect(ui->pushButton, &QPushButton::clicked, [=]{mm->show();});
    }
    

    Hi, I use such code to show the window again. First time to click the button, sub-window popup normally.
    Screenshot_20191016_094624.png
    Then I close it by up-right "x". I click the button again to show sub-window, and found it stuck with short duration´╝î and then a strange window popup like below
    Screenshot_20191016_094710.png
    The background is part of my desktop.
    When I resize the sub-window. It's background redraw to normal.
    I have two question.

    1. What may cause the short stuck
    2. How to make the background normal by code, not by hand.

    Thanks!


  • Lifetime Qt Champion

    What Qt version do you use? Please check with 5.12.5 since there were problems with 5.12.3/.4 wrt to your problem iirc.



  • @Christian-Ehrlicher
    Oh, Thanks. My version is 5.12.4.
    I use another version 5.9.3 and the bug is gone.


Log in to reply