#include #include #include #include #include #include #include QT_CHARTS_USE_NAMESPACE int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow mw; // Must have QMenuBar to see the problem // QMdiSubWindow maximizes differently when the menu bar is present mw.setMenuBar(new QMenuBar); QMdiArea mdi; mw.setCentralWidget(&mdi); // Can only reproduce the issue using a QChartView // Even QGraphicsView didn't have the issue. // Also, MDI area can only have one subwindow QChartView cv; QMdiSubWindow *sw = mdi.addSubWindow(&cv); QTimer::singleShot(1000, sw, &QMdiSubWindow::showMaximized); // Maximize the SubWindow QTimer::singleShot(2000, sw, &QMdiSubWindow::showNormal); // Take it back to normal QTimer::singleShot(3000, &mw, [&mw] { mw.hide(); // Hide the MainWindow mw.grab(); // This has to be done after hide() QTimer::singleShot(0, &mw, &QMainWindow::show); // Must call show() from the event loop }); // Repainting the Window and the viewport of the QChartView causes the window to re-appear QTimer::singleShot(5000, sw, SLOT(repaint())); QTimer::singleShot(5000, cv.viewport(), SLOT(repaint())); mw.show(); return a.exec(); }