PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 493 - __eq__ and friends not implemented for QKeyEvent == QKeySequence
: __eq__ and friends not implemented for QKeyEvent == QKeySequence
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: PySide
: 1.0.0 beta2
: All All
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2010-11-23 13:24 EET by Dan Halbert
Modified: 2011-01-06 16:19 EET (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Halbert 2010-11-23 13:24:45 EET
Qt C++ implements operator== for QKeyEvent == QKeySequence and QKeySequence ==
QKeyEvent.

Analogously, PyQt implements QKeyEvent.__eq__() and QKeyEvent.__ne__().
But PySide does not.

(PyQt also implements len() and a raft of other comparison operators for
QKeyEvent; I did not check to see if these were in PySide.)

My workaround is to use QKeyEvent.matches(). It was a bit confusing that I
could of course use ==, but it was not actually testing what I expected.

Interactive test program: When you run this and then type Ctrl+C, you'll get an
event when you hold down Ctrl, and then again when you press C.

#--------------------------
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#from PySide.QtCore import *
#from PySide.QtGui import *

class MyLabel(QLabel):
    def keyPressEvent(self, key_event):
        print "key_event.matches(QKeySequence.Copy):",
key_event.matches(QKeySequence.Copy)
        print "key_event == QKeySequence.Copy:", key_event == QKeySequence.Copy
        print "QKeySequence.Copy== key_event:", QKeySequence.Copy == key_event
        print
        key_event.accept()

app = QApplication([])
w = MyLabel('Try Ctrl+C on this widget')
w.show()
app.exec_()
Comment 1 Matti Airas 2010-11-23 16:34:26 EET
Thanks for the bug and the test case. Prioritizing P3. This should be fixed in
the upcoming sprints.
Comment 2 Hugo Parente Lima 2010-12-29 19:16:26 EET
Fixed in commits:

apiextractor/ff931611b12b46eb138ffd364b24495792f9d968
shiboken/1faf14ceb8a3eff5ecf3b92ce846970171f9e2b8
shiboken/a24e6bcd2251b6cbd78ec4e69a2b6b591738e697
pyside/249a87808ac42644fecf9b8787b0ca6c757a2f4b

Thanks for the report =].
Comment 3 renato filho 2011-01-06 16:19:28 EET
released on beta3