Results 1 to 3 of 3

Thread: React on KeyEvent inside QTreeWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: React on KeyEvent inside QTreeWidget

    You need to intercept key events going to the tree widget not the main window.

    Event filter seems to be easiest solution in this case:
    Qt Code:
    1. MainWindow::MainWindow( QWidget* parent )
    2. : QMainWindow( parent )
    3. {
    4. [...] // your setup
    5.  
    6. this->tree->installEventFilter( this );
    7. }
    8.  
    9. bool MainWindow::eventFilter( QObject* o, QEvent* e )
    10. {
    11. if( o == this->tree && e->type() == QEvent::KeyRelease )
    12. {
    13. label->setText(tree->currentItem()->text(0));
    14. }
    15.  
    16. return false;
    17. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to Spitfire for this useful post:

    Raadush (10th April 2012)

Similar Threads

  1. Replies: 0
    Last Post: 11th January 2011, 09:00
  2. QTreeWidget row updates inside QDialog
    By innerhippy in forum Qt Programming
    Replies: 4
    Last Post: 19th December 2008, 18:32
  3. Drag and Drop item inside QTreeWidget
    By nina1983 in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2008, 11:43
  4. ScrollBar inside QTreeWidget is Blurring on Scrolling
    By santosh.kumar in forum Qt Programming
    Replies: 0
    Last Post: 11th April 2008, 14:33
  5. Resizing a QTreeWidget inside a layout
    By bruccutler in forum Qt Programming
    Replies: 11
    Last Post: 27th March 2007, 15:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.