I tried the following lines:
setWindowState(Qt::WindowNoState); // F1
resize(imageSize); // F2
showNormal(); // F1
resize(imageSize); // F2
setWindowState(Qt::WindowNoState); // F1
setGeometry(QRect({}, imageSize)); // F2
showNormal(); // F1
setGeometry(QRect({}, imageSize)); // F2
setUpdatesEnabled(false);
setWindowState(Qt::WindowNoState); // F1
setUpdatesEnabled(true);
resize(imageSize); // F2
And the same combinations of F1 and F2 as in 1 to 4.
Result:
Whenever the Window state was Maximised or Fullscreen before running the part of code, the effect of F2 was undone (the resize occurred and then in < 500ms the window went back to the state before the resize(...)).
So I tried:
QTimer::singleShot(delay_time, [this, imageSize]() { resize(imageSize); });
- With
delay_time=0the window acted the same as cases 1 to 5. - With
delay_time=10I got a visual glitch which continued until I resized the window again (via mouse interaction or via in program code).- I will try and attach a suitable screen recording for it.
- With
delay_time=100, the window acted as expected. But 100ms is a long enough value to be user noticeable.
The full code is at Aditya Tolikar / qView_nolfs · GitLab
The changes in question are in the file src/mainwindow.cpp
The latest commit has the workaround as shown in Case 8. You can play around with it to see what it does on other systems.
I am interested in understanding what might be the cause of the problem. Whether it has to do with kwin or Qt or my code itself.