[PyQt] QVector Bug?

Darryl Wallace darryl.wallace at prosensus.ca
Thu Feb 12 19:14:35 GMT 2009


Ok so I guess it's not technically a 'QVector' since QVector is not 
explictly implemented.  Regardless, the code used to work in PyQt4.4.2 
for QPolygon.

And I solve the problem using .at() instead of the __getitem__ / [] operator

darryl

Darryl Wallace wrote:
> Hello,
>
> I may have encountered an error with using QPolygon (or I guess any 
> QVector<QPoint> / QVector<QPointF>)  It doesn't appear to be able to 
> set the values.
>
> The following code is my test:
> ----------------
> from PyQt4 import Qt
>
> from random import random
>
> f=Qt.QPolygonF(5)
>
> print "Before"
> for i in range(5):
>    print f[i].x(), f[i].y()
>
> print "After"
> for i in range(5):
>    newX=random()
>    newY=random()
>    f[i].setX(newX)
>    f[i].setY(newY)
>    print newX,newY,"   /   ",f[i].x(),f[i].y()
> -------------------
> Using PyQt4.4.4, Qt 4.4.0, SIP 4.7.9, Python 2.5.2, Windows
>
> You can see that running the program yields no change.  The QVector 
> documentation for the [] operator states that:
>
> T & QVector::operator[] ( int /i/ )
> Returns the item at index position /i/ as a modifiable reference.
> /i/ must be a valid index position in the vector (i.e., 0 <= /i/ < 
> size <cid:part1.06020005.08010804 at prosensus.ca>()).
> See also at <cid:part2.01070405.06030700 at prosensus.ca>() and value 
> <cid:part3.08090504.08050301 at prosensus.ca>().
>
> So I think it should still work.  I can verify that the above this 
> works code works for PyQt4.4.2, Qt 4.4.0, SIP 4.7.7, Python 2.5.2 in 
> Linux.
>
> Is there a work-around available for the near future?
>
> Thanks
> Darryl
>
>
>
>


More information about the PyQt mailing list