diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 0d7b473682..51ed04bcf6 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -157,6 +157,7 @@ type function getFrameGeometry: TRect; function getGeometry: TRect; virtual; function getVisible: Boolean; virtual; + function getParent: QWidgetH; function getPos: TQtPoint; function getSize: TSize; function getText: WideString; virtual; @@ -2475,6 +2476,11 @@ begin Result := QWidget_isVisible(Widget); end; +function TQtWidget.getParent: QWidgetH; +begin + Result := QWidget_parentWidget(Widget); +end; + function TQtWidget.getPos: TQtPoint; begin QWidget_pos(Widget, @Result); diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index a9ad4c1e95..d98128603a 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -3119,6 +3119,7 @@ end; function TQtWidgetSet.GetWindowRect(Handle: HWND; var ARect: TRect): Integer; var APos: TQtPoint; + AParent: QWidgetH; begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI GetWindowRect]'); @@ -3126,9 +3127,19 @@ begin Result := 0; +{ // this code doesnot work sometimes - why? Maybe qt bug? + // to test bug one can create 4 pannels with 0 sizes and aligned to differnt sides + // then aligned to left and to right panel will return same value + APos.x := 0; APos.y := 0; QWidget_mapToGlobal(TQtWidget(Handle).Widget, @APos, @APos); +} + APos := TQtWidget(Handle).getPos; + AParent := TQtWidget(Handle).getParent; + if AParent <> nil then + QWidget_mapToGlobal(AParent, @APos, @APos); + ARect.Left := APos.x; ARect.Top := APos.y; ARect.Bottom := ARect.Top + TQtWidget(Handle).getHeight;