[PyQt] QVector Bug?

Darryl Wallace darryl.wallace at prosensus.ca
Thu Feb 12 18:58:26 GMT 2009


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




-- 
______________________________________
Darryl Wallace: Project Leader
ProSensus Inc.
McMaster Innovation Park
175 Longwood Road South
Hamilton, Ontario, L8P 0A1
Canada        (GMT -05:00) 

Tel:       1-905-528-9136
Fax:       1-905-546-1372

Web site:  http://www.prosensus.ca/
______________________________________



More information about the PyQt mailing list