Force creation of native menu bar when main window is shown

Native menu bar recreation is hooked up to the focusWindowChanged signal in
QGuiApplication. Emittng this when the window is shown ensures that Qt
creates the menubar at the correct time.

Fixes gh2k/fractorium#1
This commit is contained in:
Simon Detheridge 2015-07-29 14:55:55 +01:00
parent 0e8e63202d
commit 916863dd0a
2 changed files with 14 additions and 0 deletions

View File

@ -349,6 +349,19 @@ void Fractorium::resizeEvent(QResizeEvent* e)
QMainWindow::resizeEvent(e);
}
/// <summary>
/// Respond to a show event to ensure Qt updates the native menubar.
/// On first create, Qt can fail to create the native menu bar properly,
/// but telling it that this window has become the focus window forces
/// it to refresh this.
/// <param name="e">The event</param>
void Fractorium::showEvent(QShowEvent *e)
{
// tell Qt to refresh the native menubar from this widget
emit qGuiApp->focusWindowChanged(windowHandle());
QMainWindow::showEvent(e);
}
/// <summary>
/// Stop rendering and block before exiting.
/// Called on program exit.

View File

@ -302,6 +302,7 @@ protected:
virtual void dragEnterEvent(QDragEnterEvent* e) override;
virtual void dragMoveEvent(QDragMoveEvent* e) override;
virtual void dropEvent(QDropEvent* e) override;
virtual void showEvent(QShowEvent *e) override;
private:
void InitMenusUI();