Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.6.2
-
None
-
Reported as a problem on Snow Leopard and Windows 7.
-
b912cac358a0a84f72f727767772caad22062a45
Description
When pressing Qt::Key_Delete when inside a QAbstractItemView subclass the keypress is erroneously accepted.
1. Set keyboard focus to a QAbstractItemView subclass (select a row in the view)
2. Put a breakpoint in QAbstractItemView::keyPressEvent
3. Press the delete key
4. Step through QAbstractItemView::keyPressEvent until you reach line 2319 in qabstractitemview.cpp:
if (!event->text().isEmpty() && !modified && !edit(currentIndex(), AnyKeyPressed, event)) { keyboardSearch(event->text()); event->accept(); } else { event->ignore(); }
event->text().isEmpty() returns false.
The following patch seems to fix the problem in a cross platform way, but shouldn't text() be empty for invisible characters ?
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index cbd9a8a..fa8214b 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2260,6 +2260,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) case Qt::Key_Escape: case Qt::Key_Shift: case Qt::Key_Control: + case Qt::Key_Delete: event->ignore(); break; case Qt::Key_Space: