Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.0
-
None
Description
I created an MDI application and noticed that the first visible window had issues. Primarily, the move and resize events didn't seem to be working at all. Maximizing and unmaximizing, or opening a second window would fix the issue.
In the end, I tracked it down to what I guess is an ordering issue with my code (when the QMdiSubWindow is attached to the QMdiArea vs when the child widget is setup), but it seems to me that since Qt could eventually figure out how to work properly, it should perhaps always work properly?
Here is a trivial example that demonstrates the issue:
#include <QApplication> #include <QMdiArea> #include <QMdiSubWindow> #include <QLabel> #include <QHBoxLayout> static bool bad = true; int main(int argc, char *argv[]) { QApplication a(argc, argv); QMdiArea *window = new QMdiArea; window->show(); QWidget *widget = new QWidget; QMdiSubWindow *subWindow; if (bad) { subWindow = new QMdiSubWindow(window); } else { subWindow = new QMdiSubWindow; } subWindow->setWidget(widget); subWindow->setAttribute(Qt::WA_DeleteOnClose); QLabel *label = new QLabel("This is just some text"); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(label); widget->setLayout(layout); if (!bad) { window->addSubWindow(subWindow); } widget->show(); return a.exec(); }
- Run the app and try to move or resize the subwindow.
- Observe the painting errors.
- Maximize (double click the title bar) and unmaximize the subwindow.
- Observe that painting is corrected.
- Change the bool bad to false and re-run the app.
- Observe that there are no painting errors.