View Issue Details

IDProjectCategoryView StatusLast Update
0026175LazarusWidgetsetpublic2014-09-12 18:27
ReporterZeljan Rikalo Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.3 (SVN) 
Target Version1.2.4 
Summary0026175: Qt: child widgets with assigned FOwner as clientRect should return FOwner clientRect
Description*TQtTabBar (if owner is TQtTabWidget and LCLObject is TPageControl)
*TQtScrollBar - if owner is TQtAbstractScrollArea
*TQtMainWindow - must return WindowArea clientRect, not itself contentsRect.
TagsNo tags attached.
Fixed in Revision45059
LazTarget1.2.6
WidgetsetQT
Attached Files

Relationships

related to 0026174 closedZeljan Rikalo Qt: QGroupBox and QLCLAbstractScrollArea sizing errors 

Activities

Zeljan Rikalo

2014-05-17 16:45

developer  

qtclientrect_with_owner.diff (3,144 bytes)   
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 45052)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -642,6 +642,7 @@
     function getAcceptDropFiles: Boolean; override;
     function GetContainerWidget: QWidgetH; override;
     procedure grabMouse; override;
+    function getClientBounds: TRect; override;
     function getClientOffset: TPoint; override;
 
     function getText: WideString; override;
@@ -4511,23 +4512,68 @@
 end;
 
 function TQtWidget.getClientBounds: TRect;
+{$IFDEF VerboseQtResizeError}
+var
+  R: TRect;
+{$ENDIF}
 begin
   QWidget_contentsRect(getContainerWidget, @Result);
+  {only when FOwner implements it's own getClientBounds !
+   Valid for FOwner: TQtTabWidget, TQtAbstractScrollArea and it's successors}
+  if (FOwner <> nil) and
+    not (ChildOfComplexWidget in [ccwComboBox]) then
+  begin
+    {$IFDEF VerboseQtResizeError}
+    R := FOwner.getClientBounds;
+    if not EqualRect(R, Result) then
+      DebugLn('WARNING: Providing wrong clientRect ',dbgs(Result),' for ',dbgsName(LCLObject),' from ',dbgsName(Self),' FOwner ',dbgsName(FOwner),' ==>',dbgs(R));
+    Result := R;
+    {$ELSE}
+    Result := FOwner.getClientBounds;
+    {$ENDIF}
+  end;
 end;
 
 function TQtWidget.getClientOffset: TPoint;
 var
   P: TQtPoint;
   R: TRect;
+  {$IFDEF VerboseQtResizeError}
+  Pt: TPoint;
+  {$ENDIF}
 begin
   // we need an offset of container inside widget, but if container = widget then
   // offset = 0
+  {$IFDEF VerboseQtResizeError}
   if Widget <> GetContainerWidget then
     QWidget_pos(GetContainerWidget, @P)
   else
     P := QtPoint(0, 0);
   R := getClientBounds;
   Result := Point(P.x + R.Left, P.y + R.Top);
+  if (FOwner <> nil) and
+    not (ChildOfComplexWidget in [ccwComboBox]) then
+  begin
+    Pt := FOwner.getClientOffset;
+    if (Pt.x <> Result.x) or (Pt.y <> Result.y) then
+      DebugLn('WARNING: Providing wrong clientOffset ',dbgs(Result),' for ',dbgsName(LCLObject),' from ',dbgsName(Self),' FOwner ',dbgsName(FOwner),' ==>',dbgs(Pt));
+    Result := Pt;
+  end;
+  {$ELSE}
+  if (FOwner <> nil) and
+    not (ChildOfComplexWidget in [ccwComboBox]) then
+  begin
+    Result := FOwner.getClientOffset;
+  end else
+  begin
+    if Widget <> GetContainerWidget then
+      QWidget_pos(GetContainerWidget, @P)
+    else
+      P := QtPoint(0, 0);
+    R := getClientBounds;
+    Result := Point(P.x + R.Left, P.y + R.Top);
+  end;
+  {$ENDIF}
 end;
 
 procedure TQtWidget.grabMouse;
@@ -6639,6 +6685,20 @@
   {$ENDIF}
 end;
 
+function TQtMainWindow.getClientBounds: TRect;
+begin
+  {$IFDEF QTSCROLLABLEFORMS}
+  if Assigned(ScrollArea) and
+    {forms which have parent eg.docked must always provide
+     ScrollArea clientRect, while others provide such info
+     only when they are mapped.}
+    (testAttribute(QtWA_Mapped) or (LCLObject.Parent <> nil)) then
+      Result := ScrollArea.getClientBounds
+  else
+  {$ENDIF}
+  Result:=inherited getClientBounds;
+end;
+
 function TQtMainWindow.getClientOffset: TPoint;
 begin
   {$IFDEF QTSCROLLABLEFORMS}
qtclientrect_with_owner.diff (3,144 bytes)   

Zeljan Rikalo

2014-05-17 17:04

developer   ~0075041

Do not close yet.

Zeljan Rikalo

2014-05-18 11:39

developer   ~0075062

Last edited: 2014-05-18 11:40

View 2 revisions

Final commit about sizing is r45071

Issue History

Date Modified Username Field Change
2014-05-17 11:04 Zeljan Rikalo New Issue
2014-05-17 11:04 Zeljan Rikalo Status new => assigned
2014-05-17 11:04 Zeljan Rikalo Assigned To => Zeljan Rikalo
2014-05-17 11:04 Zeljan Rikalo File Added: qtclientrect_with_owner.diff
2014-05-17 16:45 Zeljan Rikalo File Deleted: qtclientrect_with_owner.diff
2014-05-17 16:45 Zeljan Rikalo File Added: qtclientrect_with_owner.diff
2014-05-17 17:04 Zeljan Rikalo Fixed in Revision => 45059
2014-05-17 17:04 Zeljan Rikalo Note Added: 0075041
2014-05-17 17:04 Zeljan Rikalo Status assigned => resolved
2014-05-17 17:04 Zeljan Rikalo Resolution open => fixed
2014-05-18 11:39 Zeljan Rikalo Note Added: 0075062
2014-05-18 11:40 Zeljan Rikalo Relationship added related to 0026174
2014-05-18 11:40 Zeljan Rikalo Note Edited: 0075062 View Revisions
2014-09-12 18:26 Zeljan Rikalo LazTarget - => 1.2.6
2014-09-12 18:27 Zeljan Rikalo Status resolved => closed