Qt6: Fixed flickering MainWindow (#4452)

* Qt6: Fixed flickering MainWindow

When opening a Mapchart for the first time after start of GC, the
MainWindow used to shrink and be maximized again afterwards
automatically, matching the description in
https://forum.qt.io/topic/141398/qwebengineview-closes-reopens-window-when-added-dynamically

By adding and removing a QWebEngineView before showing MainWindow,
this flicker can be avoided

* Added empty HTML to RideMapWindow

This fix avoids flicker for the RideMapWindow in (un-)maximized windows
(only if the chart was already part of the layout on startup)
This commit is contained in:
Joachim Kohlhammer
2024-03-10 13:28:24 +01:00
committed by GitHub
parent 642eae96cb
commit a1f02e925f
2 changed files with 14 additions and 0 deletions

View File

@@ -137,6 +137,7 @@ RideMapWindow::RideMapWindow(Context *context, int mapType) : GcChartWindow(cont
view->setContentsMargins(0,0,0,0);
view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
view->setAcceptDrops(false);
view->page()->setHtml("<html></html>");
layout->addWidget(view);
HelpWhatsThis *help = new HelpWhatsThis(view);

View File

@@ -444,6 +444,19 @@ MainWindow::MainWindow(const QDir &home)
tablayout->addWidget(viewStack);
setCentralWidget(central);
#if QT_VERSION >= 0x060000
/*----------------------------------------------------------------------
* Hack to avoid a flickering MainWindow when showing a QWebEngineView in a chart, e.g. a Map:
* Temporarily add a dummy QWebEngineView with some random content before the MainWindow is shown
* https://forum.qt.io/topic/141398/qwebengineview-closes-reopens-window-when-added-dynamically
*--------------------------------------------------------------------*/
QWebEngineView *dummywev = new QWebEngineView();
dummywev->page()->setHtml("<html></html>");
mainLayout->addWidget(dummywev);
mainLayout->removeWidget(dummywev);
delete dummywev;
#endif
/*----------------------------------------------------------------------
* Application Menus
*--------------------------------------------------------------------*/