Results 1 to 4 of 4

Thread: On Press Space Key item in QTreeWidget gets checked.

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    42
    Thanked 1 Time in 1 Post

    Default On Press Space Key item in QTreeWidget gets checked.

    Working in Qt4.6 on mac os 10.6 , Whenever i press Space key item in QTreeWidget gets checked, i am trying to handle it using keyPressEvent but nothing happens.

    Qt Code:
    1. void MyTreeWidget::keyPressEvent ( QKeyEvent * event )
    2. {
    3. this->QTreeWidget::keyPressEvent(event);
    4. if(event->key()==Qt::Key_Space)
    5. {
    6. event->ignore();
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    What should i do so that nothing happens on press of space key.

    Regards,
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: On Press Space Key item in QTreeWidget gets checked.

    Try not calling the superclass keyPressEvent() if you don't want it to handle the key press.

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    42
    Thanked 1 Time in 1 Post

    Default Re: On Press Space Key item in QTreeWidget gets checked.

    I used keyPressEvent() for handling the space key, if i not use this then also it wont works, On press space key the item in treeWidget gets checked.
    Always Believe in Urself
    Merry

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

    Default Re: On Press Space Key item in QTreeWidget gets checked.

    You're ignoring the even after passing it to the base clase, no wonder that doesn't change widget's bahaviour.

    Put line 3 at the end of the function then event will get ignored before it's processed.

    Also, could you elaborate what you mean by 'checked'?
    Is there a checkbox that gets checked or widget gets higlighted like when it's selected or maybe something else?
    I'm bit confused here.

Similar Threads

  1. Find the item under the mouse press
    By sajis997 in forum Newbie
    Replies: 5
    Last Post: 18th August 2011, 14:24
  2. Replies: 0
    Last Post: 1st October 2010, 16:09
  3. Replies: 2
    Last Post: 13th September 2008, 14:55
  4. Replies: 2
    Last Post: 1st August 2008, 17:58
  5. Checked item in QTreeWidget?
    By vishal.chauhan in forum Qt Programming
    Replies: 18
    Last Post: 3rd January 2008, 21:18

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.