[PyQt] Is this a bug or ?

Gilles CHAUVIN gcnweb at gmail.com
Wed Mar 19 18:37:55 GMT 2008


I'm new to this list so I apologize if this has been asked / reported
before. I'm trying to add drag n' drop support to a QListWidget. Here
is my current test code:

from PyQt4.Qt import *

class ListWidget(QListWidget):
    def __init__(self, parent=None):
        QListWidget.__init__(self, parent)

        self.startPos = QPoint();

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.startPos = event.pos()
        QListWidget.mousePressEvent(self, event)
        print "mPE - Pos: %dx%d" % (self.startPos.x(), self.startPos.y())

    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            print "mME - Pos: %dx%d" % (self.startPos.x(), self.startPos.y())

While the app is running, I left-click on my "ListWidget" and then
(while holding the button clicked) move my mouse. The output looks
mPE - Pos: 56x257
mME - Pos: 137x129
mME - Pos: 149x105
mME - Pos: 155x87
mME - Pos: 159x75
mME - Pos: 161x67
mME - Pos: 163x57
mME - Pos: 165x49
mME - Pos: 165x48

I don't understand why self.startPos keeps changing whenever I move
the mouse ?! Am I doing something wrong or is there a bug somewhere in
Python / SIP / PyQt / Qt ?

I'm running the following software versions (under ArchLinux):
- python 2.5.2
- qt 4.3.3
- sip 4.7.3
- pyqt 4.3.3

Thanks for your help.


More information about the PyQt mailing list