[PyKDE] QPointArray Corruption

Yannick Gingras ygingras at kubiktech.com
Mon Jan 20 17:36:01 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I have a problem here on PyQt 3.5.

The QPointArray.putPoints() function store a corrupted vertion of the point
list but the constructor of QPointArray handle it without any problems.

test code :

from qt import *
import os
import sys

TEST_IMG_PATH = "unittest.png"

IMG_WIDTH  = 100
IMG_HEIGHT = 100
BACK_COL  = (0, 0, 255)
FRONT_COL = (0, 255, 0)

def makeTestImage(filename):
    """create an image : a losange on a plain background"""
    backCol = QColor(*BACK_COL)
    frontCol = QColor(*FRONT_COL)
    pixmap = QPixmap( IMG_WIDTH, IMG_HEIGHT )
    pixmap.fill(backCol)
    painter = QPainter(pixmap)

    coords = [ IMG_WIDTH/2,   IMG_HEIGHT/4,
               IMG_WIDTH*3/4, IMG_HEIGHT/2,
               IMG_WIDTH/2,   IMG_HEIGHT*3/4,
               IMG_WIDTH/4,   IMG_HEIGHT/2 ]


    pArray = QPointArray()
    pArray.putPoints( 0, coords )
    for i in range(pArray.size()):
        print pArray.point(i)

    painter.moveTo(*coords[:2])
    painter.setBrush(frontCol)
    painter.setPen(frontCol)
    painter.drawPolygon(pArray)
    painter.end()
    pixmap.save(filename, "PNG")


if __name__ == "__main__":
    app = QApplication(sys.argv)
    makeTestImage(TEST_IMG_PATH)

result :
[ygingras at ogre tmp]$ python -c "import qt; print qt.PYQT_VERSION"
3.5
[ygingras at ogre tmp]$ python testImage.py
(50, 25)
(75, 50)
(50, 75)
(25, 50)
(1953721961, 73)
(50, 25)
(75, 50)
(50, 75)

Would it be preferable to send a PyUnit TestCase ?

The hi level interface to QPointArray with point lists is really conveniant,
congratulation on this one.

- --
Yannick Gingras
Coder for OBB : Omniscient Bluff Bassariscidae
http://OpenBeatBox.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+LCU9rhy5Fqn/MRARAkncAKCPqVXu5llKnv9xoygR3YW36OrnZgCfdkns
emQ3IBer2dZAMzsV3HFd8mk=
=EwUL
-----END PGP SIGNATURE-----




More information about the PyQt mailing list