diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 3f3bf13845..38360c462c 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -1004,9 +1004,9 @@ begin QEventHide: SlotShow(False); QEventClose: begin - Result:=True; - QEvent_ignore(Event); - SlotClose; + Result := True; + QEvent_ignore(Event); + SlotClose; end; QEventDestroy: SlotDestroy; QEventFocusIn: SlotFocus(True); @@ -2185,9 +2185,6 @@ end; function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH; var w: QWidgetH; -{$ifdef USE_QT_4_3} - mdihandle: QMdiAreaH; -{$endif} begin // Creates the widget {$ifdef VerboseQt} @@ -2241,11 +2238,18 @@ begin {$ifdef USE_QT_4_3} if (LCLObject is TCustomForm) and (TCustomForm(LCLObject).FormStyle = fsMDIChild) then begin - Result := QMdiSubWindow_create(niL, QtWindow); - - mdiHandle := TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle; - if Assigned(mdiHandle) then - QMdiArea_addSubWindow(mdiHandle, QMdiSubWindowH(Result), QtWindow); + + if TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle = nil + then + raise Exception.Create('MDIChild can be added to MDIForm only !'); + + Result := QMdiSubWindow_create(nil, QtWindow); + + // QMdiSubWindow already have an layout + LayoutWidget := QBoxLayoutH(QWidget_layout(Result)); + if LayoutWidget <> nil + then + QBoxLayout_destroy(LayoutWidget); end else Result := QWidget_create(nil, QtWindow); diff --git a/lcl/interfaces/qt/qtwsforms.pp b/lcl/interfaces/qt/qtwsforms.pp index 4ac93535fc..4909c7ccb9 100644 --- a/lcl/interfaces/qt/qtwsforms.pp +++ b/lcl/interfaces/qt/qtwsforms.pp @@ -35,7 +35,7 @@ uses {$endif} qtwidgets, // LCL - SysUtils, Controls, LCLType, Forms, + SysUtils, Classes, Controls, LCLType, Forms, // Widgetset InterfaceBase, WSForms, WSLCLClasses; @@ -144,6 +144,7 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl; var QtMainWindow: TQtMainWindow; Str: WideString; + R: TRect; begin {$ifdef VerboseQt} WriteLn('[TQtWSCustomForm.CreateHandle] Height: ', IntToStr(AWinControl.Height), @@ -154,7 +155,8 @@ begin QtMainWindow := TQtMainWindow.Create(AWinControl, AParams); - if (TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]) and + if (TCustomForm(AWinControl).ShowInTaskBar in [stDefault, stNever]) and not + (TCustomForm(AWinControl).FormStyle in [fsMDIChild]) and (Application <> nil) and (Application.MainForm <> nil) and (Application.MainForm.HandleAllocated) and @@ -173,6 +175,20 @@ begin // Sets Various Events QtMainWindow.AttachEvents; + + {$ifdef USE_QT_4_3} + if (TCustomForm(AWinControl).FormStyle in [fsMDIChild]) + and (Application.MainForm.FormStyle = fsMdiForm) + then + begin + QWidget_geometry(QtMainWindow.MenuBar.Widget, @R); + QMdiArea_addSubWindow(TQtMainWindow(Application.MainForm.Handle).MDIAreaHandle, QtMainWindow.Widget, QtWindow); + AWinControl.Height := AWinControl.Height + R.Bottom; + {TODO: Show MDIChild Left&Top +10 of last created mdi child} + AWinControl.Left := 0; + AWinControl.Top := 0; + end; + {$endif} // Return the handle Result := THandle(QtMainWindow); @@ -286,7 +302,7 @@ end; ------------------------------------------------------------------------------} class procedure TQtWSCustomForm.ShowModal(const ACustomForm: TCustomForm); begin - {TODO: fix cpu burning , we need an sleep(0) in LCL modal loop} + end; {------------------------------------------------------------------------------