[PyQt] Comparison of QPointF
Vincent Vande Vyvre
vincent.vandevyvre at swing.be
Thu Mar 28 11:10:37 GMT 2013
Hi,
I need to check the proximity of two QPointF for implement a snap grid
behaviour, but the comparison of the two points is inexact or fail with
Python3.
Platform Linux-3.2.0-39-generic-x86_64-with-Ubuntu-12.04-precise
Python 2.7.3
Qt 4.8.1
PyQt 4.9.1
Sip 4.13.2
>>> from PyQt4 import QtCore
>>> QtCore.QPointF(172.0, 106.0) < QtCore.QPointF(5.0, 5.0)
True
>>> QtCore.QPointF(5.0, 5.0) < QtCore.QPointF(172.0, 106.0)
False
>>> QtCore.QPointF(-5.0, -5.0) < QtCore.QPointF(172.0, 106.0)
True
>>> QtCore.QPointF(5.0, 5.0) < QtCore.QPointF(-172.0, -106.0)
False
>>> QtCore.QPointF(172.0, 106.0) > QtCore.QPointF(5.0, 5.0)
False
>>> QtCore.QPointF(172.0, 106.0) == QtCore.QPointF(172.0, 106.0)
True
-------------------------------------------------------------
Python 3.2.3
Qt 4.8.1
PyQt 4.9.1
Sip 4.13.2
>>> from PyQt4 import QtCore
>>> QtCore.QPointF(5.0, 5.0) < QtCore.QPointF(172.0, 106.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: QPointF() < QPointF()
>>> QtCore.QPointF(167.0, 101.0) == QtCore.QPointF(167.0, 101.0)
True
>>> QtCore.QPointF(167.0, 101.0) <= QtCore.QPointF(167.0, 101.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: QPointF() <= QPointF()
Thanks
More information about the PyQt
mailing list