[PyQt] Variant compare
phil at riverbankcomputing.com
Fri Jun 5 11:44:23 BST 2009
On Fri, 05 Jun 2009 17:14:52 +0700, Alexandr N Zamaraev <tonal at promsoft.ru>
> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt4 import QtCore
> >>> QtCore.QVariant(1) == QtCore.QVariant(1)
> >>> QtCore.QVariant(int) == QtCore.QVariant(int)
Under the covers Python objects are wrapped in a class that manages their
reference counts so that you (and Qt internals) can safely copy QVariant
around. It's those wrappers that are being compared not the object that
they are wrapping.
It would be nice if the QVariant == operator could call the wrapper's ==
operator rather than just compare addresses.
> >>> QtCore.QVariant([1, 2]) == QtCore.QVariant([1, 2])
More information about the PyQt