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 227 - QTextEdit keyPressEvent got a QEvent instead of a QKeyEvent
: QTextEdit keyPressEvent got a QEvent instead of a QKeyEvent
Status: CLOSED WORKSFORME
Product: PySide
Classification: Unclassified
Component: QtGui
: 0.3.1
: All All
: P5 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-05-20 09:33 EEST by Benoît HERVIER
Modified: 2010-08-13 11:25 EEST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benoît HERVIER 2010-05-20 09:33:30 EEST
While subclassing a QTextEdit and the methods keyPressEvent, 

def keyPressEvent(self, e):

e is an QEvent object instead of a PySide.QtGui.QKeyEvent.

This error didn't happen in PyQt4

Traceback (most recent call last):
  File "/home/user/MyDocs/Projects/khteditor/editor_frame.py", line 109, in
eventFilter
    if object in (self.edit, self.edit.viewport()):
  File "/home/user/MyDocs/Projects/khteditor/editor.py", line 35, in
keyPressEvent
    QtGui.QTextEdit.keyPressEvent(self, e)
TypeError: 'PySide.QtGui.QTextEdit.keyPressEvent' called with wrong argument
types:
  PySide.QtGui.QTextEdit.keyPressEvent(PySide.QtCore.QEvent)
Supported signatures:
  PySide.QtGui.QTextEdit.keyPressEvent(PySide.QtGui.QKeyEvent)

So when using directly e to emit to the parent class i got an error.
Comment 1 Hugo Parente Lima 2010-06-02 14:32:24 EEST
Works for me with pyside-shiboken from git HEAD (
c161698a4014b1d73c3409c62ea93e2369abf9b8) with Qt4.7 from git, but it should
work with 4.6 and probably with Pyside 0.3.1.

I'm using this code snippet to test it:

from PySide.QtCore import *
from PySide.QtGui import *

class Foo (QTextEdit):
    def keyPressEvent(self, ev):
    print type(ev)
    return QTextEdit.keyPressEvent(self, ev)

app = QApplication([])

f = Foo()
f.show()
app.exec_()