Incorrect QDialog view in Windows 10 taskbar



  • Hello everyone!
    I have some problems with QDialog. I have a MainWindow class, where I call method callDialog() after clicking the QPushButton.
    It initializes a pointer to QDialog.

    main.cpp:

    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    

    mainwindow.h:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QPushButton>
    #include <QDialog>
    
    class MainWindow : public QWidget
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    private slots:
       void callDialog();
    
    private:
        QPushButton* _button;
        QDialog* dialog;
    };
    
    #endif // MAINWINDOW_H
    

    and mainwindow.cpp:

    #include "mainwindow.h"
    #include <QGridLayout>
    
    MainWindow::MainWindow(QWidget *parent) :QWidget(parent), dialog(0)
    {
        _button = new QPushButton("Push");
        connect(_button, SIGNAL(clicked(bool)), SLOT(callDialog()));
    
        QGridLayout* lay = new QGridLayout();
        lay->addWidget(_button);
        setLayout(lay);
    
        setMinimumSize(500, 500);
    }
    
    void MainWindow::callDialog()
    {
        if (!dialog) {
            dialog = new QDialog(this);
            dialog->setMinimumSize(200, 200);
        }
        dialog->show();
        dialog->raise();
        dialog->activateWindow();
    }
    
    MainWindow::~MainWindow()
    {
        if (dialog)
            delete dialog;
    }
    

    0_1549297501744_1.png
    This is how the program looks after pressing the button. That is all right.
    Then I close QDialog, hover my mouse over the thumbnail in the taskbar and see the open QDialog, but it is hidden
    0_1549297684263_2d7f0142-59bf-4930-9e03-8954dab925df-image.png
    If you click on the thumbnail (activate the window), QDialog will hide quickly to the correct state.

    Qt doc examples:
    0_1549297893668_d86f8f19-25f5-4a1d-b2c1-3bb53694385f-image.png
    If I use first (modal) example, then all right (QDialog hided on preview, because deleted). But i need pointer to QDialog to pass parameters from other functions to it.
    Is this a feature of the system, a Qt bug or my hand curves?


  • Qt Champions 2018

    When I open the 'About' Dialog in Visual Studio and then take a look at the taskbar preview I don't see the About dialog. Tested also other programs an none showed a dialog in the preview.



  • @Christian-Ehrlicher
    OK, but I used an example from the documentation and it didn't work properly. If u tested other programs, so it's not an OS bug. I'm trying to figure out what's wrong: my code or QDialog?


  • Qt Champions 2018

    @GreenSadFrog said in Incorrect QDialog view in Windows 10 taskbar:

    If u tested other programs, so it's not an OS bug

    I don't understand you - I tested other programs and all don't show a modal dialog box in the preview so Qt behaves the same as the rest.



  • @Christian-Ehrlicher
    OK. So can you explain me whats wrong in my code? I just copied example. By the way this code works correctly when tested on windows 7.


  • Lifetime Qt Champion

    Hi
    I dont think any thing is wrong.
    Even notepad dont show any dialogs over its preview.
    So i think its works as expected when on windows 10.

    alt text



  • @mrjj Thanks for the reply.