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; }
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
If you click on the thumbnail (activate the window), QDialog will hide quickly to the correct state.Qt doc examples:
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? -
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? -
@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. -
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. -
I ran into the same problem, where a closed QDialog would magically appear over a QMainWindow when hovering over the programs' TaskBar icon...
I understand that QDialogs do not get shown in the TaskBar thumbnail, but how does the Dialog appear out of thin air, after dismissing it??@GreenSadFrog said in Incorrect QDialog view in Windows 10 taskbar:
If you click on the thumbnail (activate the window), QDialog will hide quickly to the correct state.
The problem OP described doesn't have anything to do with the Dialog not being shown in the Thumbnail btw
Seems to be a known bug https://bugreports.qt.io/browse/QTBUG-48855