Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.8.1
-
None
Description
See minimal reproducible example below.
Steps to reproduce:
1. Compile the example.
2. Launch the example AND IMMEDIATELY switch to another app/window before example main window is created and displayed.
This way the example main windows does not receive focus and is started on background.
Now, somehow observer the debug CLI output and it is reporting this:
true QWidget(0x0)
So the ` isActiveWindow()` reports true, even if the window is covered by other apps/windows and does not have any kind of focus.
If you then alt+tab into the example window and alt+tab again out of it, the output fixes itself and displays correct `false` value (not active window).
#include "mainwindow.h" #include "./ui_mainwindow.h" #include <QApplication> #include <QTimer> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QTimer *tmr = new QTimer(this); tmr->start(1000); connect(tmr, &QTimer::timeout, this, [=]() { qDebug() << isActiveWindow(); qDebug() << QApplication::activeModalWidget(); }); } MainWindow::~MainWindow() { delete ui; }