[PyQt] Possible bug - global coordinates work but widget coordinates do not

Phil Thompson phil at riverbankcomputing.com
Thu Apr 9 13:15:30 BST 2009

On Wed, 08 Apr 2009 20:26:55 +0530, Shriramana Sharma <samjnaa at gmail.com>
> Hello first of all let me clarify that this is specific to PyQt and does
> not existing in C++/Qt.
> I am using PyQt 4.3.3 on Qt 4.4.0 on Kubuntu Hardy.
> I attach three files.
> 1. test.py is the one that demonstrates the problem.
> 2. test.cpp is the equivalent C++ version that shows no problem.
> 3. test-sol.py is the Python version that works.
> I wanted to draw a rubberband on a widget, and ended up finding this
> bug. Everytime the mouseMoveEvent is processed, the value of the
> variable rbOrigin (origin of the rubberband) is reset to the current
> event position, thereby making it impossible for a proper rubberband to
> be drawn. However, it appears that the mousePressEvent (which sets the
> value of rbOrigin) is definitely not called by mistake as I don't get
> any debug output.
> The equivalent C++ version works without problems.
> Using global coordinates on Python works around the bug but I don't see
> why.



Making an explicit copy of event.pos() in mousePressEvent() will probably
fix it.


More information about the PyQt mailing list