Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how can i react to the keyboard ESC event before closeEditor() when i edit a QTreeWidgetItem...
Forum Updated to NodeBB v4.3 + New Features

how can i react to the keyboard ESC event before closeEditor() when i edit a QTreeWidgetItem...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 754 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    how can i react to the keyboard ESC event before closeEditor() when i edit a QTreeWidgetItem...

    1 Reply Last reply
    0
    • K Offline
      K Offline
      killerman
      wrote on last edited by killerman
      #2

      Try this code:

      void YourTreeWidget::keyPressEvent(QKeyEvent *event)
      {
          if (event->key() == Qt::Key_Escape)
          {
              // Your code here
              event->accept();
          }
          else
          {
              // default implementation
              QTreeView::keyPressEvent(event); 
          }
      }
      
      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        but the closeEditor() still reacts before keyPressEvent.........

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved