[Qt] Qt bindings problem (pretty urgent)

Den Jean Den.Jean at telenet.be
Tue Apr 27 22:34:21 CEST 2010


On Tuesday 27 April 2010 21:25:32 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 :-)
> > 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)
> > > 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




More information about the Qt mailing list