[PyKDE] QPointArray problem

Phil Thompson phil at riverbankcomputing.co.uk
Tue Apr 4 12:12:45 BST 2006


On Tuesday 04 April 2006 11:41 am, Ismail Donmez wrote:
> Hi,
>
> According to Qt3 docs I can do something like this :
>
> [...]
> QPointArray a( 1 );
> a[0] = QPoint( 4, 5 );
>
> but doing the same with PyQt3 :
> >>> a = QPointArray(1)
> >>> a[0] = QPoint(4,5)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: object does not support item assignment

PyQt doesn't support everything that Qt supports.

> Another related problem is with point() :
> >>> a = QPointArray(1)
> >>> a.setPoint(0,QPoint(1,1))
> >>> type(a.point(0))
>
> <type 'tuple'>
>
> But the Qt3 documentation says point(index) should return a QPoint. This is
> important because currently you can't do something like :
>
> a = QPointArray(1)
> b = QPointArray(1)
>
> a.setPoint(0,QPoint(1,1))
> b.setPoint(0,a.point(0))
>
> Solution would be either making point(index) return a QPoint or making
> setPoint accept a tuple for second argument.

There are two point() methods that have different C++ signatures but the same 
Python signatures.

void point(uint, int *, int *)

...appears before...

QPoint point(uint)

...in the .sip file and so takes precedence. This is a PyQt bug (actually it's 
a SIP bug for not detecting it as an error).

I'm not going to "fix" this (by removing the first method and exposing the 
second) as it may break existing code. The workaround is...

a.setPoint(0, QPoint(1, 1))
x, y = a.point(0)
b.setPoint(0, x, y)

Phil




More information about the PyQt mailing list