Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8270

QAbstractItemView accept() Qt::Key_Delete erroneously.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.7.0
    • 4.6.2
    • Widgets: Itemviews
    • 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:
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes