Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2010-04

Qt bindings problem (pretty urgent)

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

zeljko

Hi Den, we have problem with copyQRectToPRect() and copyPRectToQRect(). It does not set TopLeft() TopRight() values and vice versa. I cannot implement viewOrigin functions without it since eg. viewport widget of QAbstractScrollArea can be moved by scrollbars, and it's origin is stored in TopLeft value which is TPoint type (so don't know if this can make problem).
eg. QWidget_rect(viewportWidget, @R) correctly returns viewport rect, but TopLeft isn't assigned so we cannot know what's current origin of this widget.
Please if you can update bindings ASAP so I can continue with implementation.

bindings functions that need an update (pascalbind.h) copyQRectToPRect()
copyPRectToQRect()

thanks
zeljko

Den Jean
to zeljko
zeljko wrote
Hi Den, we have problem with copyQRectToPRect() and copyPRectToQRect(). It does not set TopLeft() TopRight() values and vice versa.

QRect stores internally everything in a private x1,y1,x2,y2.

copyQRectToPRect() and copyPRectToQRect() does modify those.

long ago, we decided to fix two problems:
- OsX different memory layout of QRect
- LCL vs Qt differences with respect to rectangles including or not the right/bottom edge:
http://wiki.freepascal.org/Qt4_binding#Solution:Pascalify

TopLeft and TopRight are functions that use these x1,y1,x2,y2. So whatever is set, these functions will return that, but these functions will not additionally modify with +1 or -1. (they return what is in QRect)

Show quoted text 22 lines
I cannot implement viewOrigin functions without it since eg. viewport widget of QAbstractScrollArea can be moved by scrollbars, and it's origin is stored in TopLeft value which is TPoint type (so don't know if this can make problem). eg. QWidget_rect(viewportWidget, @R) correctly returns viewport rect, but TopLeft isn't assigned so we cannot know what's current origin of this widget. Please if you can update bindings ASAP so I can continue with implementation. bindings functions that need an update (pascalbind.h) copyQRectToPRect() copyPRectToQRect() thanks zeljko _______________________________________________ Qt mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/qt
zeljko
to Den Jean
Den Jean wrote 17 lines
On Tuesday 27 April 2010 09:25:58 zeljko wrote: > Hi Den, we have problem with copyQRectToPRect() and copyPRectToQRect(). > It does not set TopLeft() TopRight() values and vice versa. QRect stores internally everything in a private x1,y1,x2,y2. copyQRectToPRect() and copyPRectToQRect() does modify those. long ago, we decided to fix two problems: - OsX different memory layout of QRect - LCL vs Qt differences with respect to rectangles including or not the right/bottom edge: http://wiki.freepascal.org/Qt4_binding#Solution:Pascalify TopLeft and TopRight are functions that use these x1,y1,x2,y2. So whatever is set, these functions will return that, but these functions will not additionally modify with +1 or -1. (they return what is in QRect)

TopRight() is wrong (type), it's bottomRight().

I don't understand what you want to say. Are you saying that our rect conversion is ok ? (I don't care for +1 -1 at the moment). QAbstractScrollArea->viewport() uses TopLeft for information about viewport origin when we ask QWidget_rect(viewport, @R);
When we move scrollbar , viewport moves, QWidget_rect() is always same, but viewport is changing QRect topLeft value (according to qt code).

If we move viewport (eg. by scrolling) qt code says that TopLeft = (0, -20) in qt bindings it says TopLeft = (0,0).
I'll try to add it to bindings just to see if it works.

zeljko

Den Jean
to zeljko
zeljko wrote
I don't understand what you want to say.

:-) idem dito

Are you saying that our rect conversion is ok ? (I don't care for +1 -1 at the moment).

I was explaining how Qt class qrect is used in binding. By using a pascal record with the same binary layout as the QRect Qt Class. Only when a qrect is returned by any qt call, the binding first calls the copy...rect... functions to fix for the +1/-1 and different OsX binary layout.
If you use the topleft (and other functions of qrect), they return the coordinates in the struct/record (w/o the +1/-1). In most cases this is what you want.

Show quoted text 7 lines
QAbstractScrollArea->viewport() uses TopLeft for information about viewport origin when we ask QWidget_rect(viewport, @R); When we move scrollbar , viewport moves, QWidget_rect() is always same, but viewport is changing QRect topLeft value (according to qt code). If we move viewport (eg. by scrolling) qt code says that TopLeft = (0, -20) in qt bindings it says TopLeft = (0,0).

I am not sure what you mean by qt code and qt binding. perhaps you should adapt a small fpc qt4 demo and add some code that demoes your problem.

I'll try to add it to bindings just to see if it works.
zeljko
to Den Jean
Den Jean wrote 16 lines
On Tuesday 27 April 2010 18:23:34 zeljko wrote: > I don't understand what you want to say. > :-) idem dito : > Are you saying that our rect > conversion is ok ? (I don't care for +1 -1 at the moment). I was explaining how Qt class qrect is used in binding. By using a pascal record with the same binary layout as the QRect Qt Class. Only when a qrect is returned by any qt call, the binding first calls the copy...rect... functions to fix for the +1/-1 and different OsX binary layout. If you use the topleft (and other functions of qrect), they return the coordinates in the struct/record (w/o the +1/-1). In most cases this is what you want.

I don't use any function of QRect I'm using QWidget_rect() from bindings which returns PRect , which comes from CopyQRectToPRect() and that one doesnt assign any value to PRect^.TopLeft. In case of QWidget_rect() QRect.topLeft() is filled with viewport offset.
Better ? :)

Show quoted text 19 lines
> QAbstractScrollArea->viewport() uses TopLeft for information about > viewport origin when we ask QWidget_rect(viewport, @R); > When we move scrollbar , viewport moves, QWidget_rect() is always same, > but viewport is changing QRect topLeft value (according to qt code). > > If we move viewport (eg. by scrolling) qt code says that TopLeft = (0, > -20) in qt bindings it says TopLeft = (0,0). I am not sure what you mean by qt code and qt binding. perhaps you should adapt a small fpc qt4 demo and add some code that demoes your problem. > I'll try to add it to bindings just to see if it works. _______________________________________________ Qt mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/qt
Den Jean
to zeljko
zeljko wrote
> I was explaining how Qt class qrect is used in binding. By using a > pascal record with the same binary layout as the QRect Qt Class. > Only when a qrect is returned by any qt call, the binding first

!! read this again :-)

Show quoted text 7 lines
> calls the copy...rect... functions to fix for the +1/-1 and different OsX > binary layout. > If you use the topleft (and other functions of qrect), they > return the coordinates in the struct/record (w/o the +1/-1). > In most cases this is what you want. I don't use any function of QRect I'm using QWidget_rect() from bindings
procedure QWidget_rect(handle: QWidgetH; retval: PRect);
http://doc.trolltech.com/4.5/qwidget.html#rect-prop

What the binding tries to do is make your life easier. By far not as easy as PyQt, but hey. So QWidget::rect returns an instance of the class QRect. If I didn't do anything special, you would have to create a class instance of Qrect using something like QRect_create and pass it to a binding function QWidget_rect(handle, retval QRectH). As to avoid that constructor part, every QRect that is a parameter or a return value of any qt method, gets replaces with a PRect and uses the copy..rect.. functions. So here you have the method rect of the class the qwidget that normally returns a qrect -> well now it returns a PRect.

which returns PRect , which comes from CopyQRectToPRect() and that one doesnt assign any value to PRect^.TopLeft.
?
TRect = record
    case Integer of
      0: (Left,Top,Right,Bottom : Longint);
      1: (TopLeft,BottomRight : TPoint);
end;
So when assigning to left/top etc -> you also assign to TopLeft
(overlapping records)
In case of QWidget_rect() > QRect.topLeft() is filled with viewport offset. Better ? :)

http://doc.trolltech.com/4.5/qwidget.html#rect-prop not that documentation says it is always (0,0,w,h)

Show quoted text 6 lines
> > QAbstractScrollArea->viewport() uses TopLeft for information about > > viewport origin when we ask QWidget_rect(viewport, @R); > > When we move scrollbar , viewport moves, QWidget_rect() is always same, > > but viewport is changing QRect topLeft value (according to qt code). > > > > If we move viewport (eg. by scrolling) qt code says that TopLeft = (0,

where does that qt code say that (might help me understand)

> > -20) in qt bindings it says TopLeft = (0,0).

just like qt doc says.

> > I am not sure what you mean by qt code and qt binding.

I am still confused, but we will get there :-)

> perhaps you should adapt a small fpc qt4 demo and add

kind regards,

Den Jean

zeljko
to Den Jean
Den Jean wrote
On Tuesday 27 April 2010 22:34:21 Den Jean wrote: > I am still confused, but we will get there :-) Do you still need something ?

No, thanks :)

zeljko