diff --git a/lcl/interfaces/qt5/qtobject.inc b/lcl/interfaces/qt5/qtobject.inc index 4b03d6b64c..2e879c7d89 100644 --- a/lcl/interfaces/qt5/qtobject.inc +++ b/lcl/interfaces/qt5/qtobject.inc @@ -1687,7 +1687,8 @@ begin begin MainWin := TQtMainWindow(Application.MainForm.Handle); MainWin.Activate; - QMenuBar_setActiveAction(QMenuBarH(MainWin.GetMenuBar.Widget), Action); + if Assigned(MainWin.MenuBar) then + QMenuBar_setActiveAction(QMenuBarH(MainWin.MenuBar.Widget), Action); end; end; diff --git a/lcl/interfaces/qt5/qtwidgets.pas b/lcl/interfaces/qt5/qtwidgets.pas index 6d0613227e..01507ce639 100644 --- a/lcl/interfaces/qt5/qtwidgets.pas +++ b/lcl/interfaces/qt5/qtwidgets.pas @@ -668,7 +668,7 @@ type procedure Activate; override; function CanAdjustClientRectOnResize: Boolean; override; - function GetMenuBar: TQtMenuBar; + function MenuBarNeeded: TQtMenuBar; function getAcceptDropFiles: Boolean; override; function GetContainerWidget: QWidgetH; override; procedure grabMouse; override; @@ -705,6 +705,7 @@ type property IsFrameWindow: Boolean read FIsFrameWindow write FIsFrameWindow; {check if our LCLObject is TCustomFrame} property FirstPaintEvent: boolean read FFirstPaintEvent write FFirstPaintEvent; {only for x11 - if firstpaintevent arrived we are 100% sure that frame is 100% accurate} property ShowOnTaskBar: Boolean read FShowOnTaskBar; + property MenuBar: TQtMenuBar read FMenuBar; public function WinIDNeeded: boolean; override; procedure AttachEvents; override; @@ -7249,7 +7250,7 @@ begin {$ENDIF} end; -function TQtMainWindow.GetMenuBar: TQtMenuBar; +function TQtMainWindow.MenuBarNeeded: TQtMenuBar; var AParent: QWidgetH; begin diff --git a/lcl/interfaces/qt5/qtwinapi.inc b/lcl/interfaces/qt5/qtwinapi.inc index d2527df0b4..034ea0be03 100644 --- a/lcl/interfaces/qt5/qtwinapi.inc +++ b/lcl/interfaces/qt5/qtwinapi.inc @@ -6143,13 +6143,13 @@ begin if AMenuWidget is TQtMenuBar then begin R := AWidget.LCLObject.ClientRect; - R1 := QtMainWindow.GetMenuBar.getGeometry; + R1 := QtMainWindow.MenuBar.getGeometry; R1.Right := R.Right; QtMenuBar.setGeometry(R1); QtMainWindow.setMenuBar(QMenuBarH(QtMenuBar.Widget)); - end - else - QtMainWindow.setMenuBar(QMenuBarH(QtMainWindow.GetMenuBar.Widget)); + end else + if Assigned(QtMainWindow.MenuBar) then + QtMainWindow.setMenuBar(QMenuBarH(QtMainWindow.MenuBar.Widget)); end; end; diff --git a/lcl/interfaces/qt5/qtwsforms.pp b/lcl/interfaces/qt5/qtwsforms.pp index 26d5ba3ba1..5a7a845033 100644 --- a/lcl/interfaces/qt5/qtwsforms.pp +++ b/lcl/interfaces/qt5/qtwsforms.pp @@ -1033,7 +1033,7 @@ begin if Assigned(TCustomForm(AWinControl).Menu) then begin AWin := TQtMainWindow(AWinControl.Handle); - AWin.GetMenuBar.sizeHint(@ASize); + AWin.MenuBar.sizeHint(@ASize); // geometry isn't updated yet if ASize.cy < 10 then ASize.cy := 0; diff --git a/lcl/interfaces/qt5/qtwsmenus.pp b/lcl/interfaces/qt5/qtwsmenus.pp index 879ff6f762..03a83fa5a9 100644 --- a/lcl/interfaces/qt5/qtwsmenus.pp +++ b/lcl/interfaces/qt5/qtwsmenus.pp @@ -442,9 +442,9 @@ begin ((AParent is TCustomForm) or (AParent is TCustomFrame)) then begin if (AParent is TCustomForm) then - MenuBar := TQtMainWindow(TCustomForm(AParent).Handle).GetMenuBar + MenuBar := TQtMainWindow(TCustomForm(AParent).Handle).MenuBarNeeded else - MenuBar := TQtMainWindow(TCustomFrame(AParent).Handle).GetMenuBar; + MenuBar := TQtMainWindow(TCustomFrame(AParent).Handle).MenuBarNeeded; Result := HMENU(MenuBar); end else begin