Results 1 to 17 of 17

Thread: qpushbutton setfocus signal

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qpushbutton setfocus signal

    Quote Originally Posted by skuda View Post
    when i press the enter in the doublespinbox, the okButton get the focus and automatically it is clicked.
    Only "default" buttons react to return/enter and they disregard the focus in that matter.

    Try this:
    Qt Code:
    1. ...
    2. connect(testButton, SIGNAL(clicked()), SLOT(testButtonPressed()));
    3. connect(spinBox, SIGNAL(editingFinished()), SLOT(testing()));
    4. connect(emitButton, SIGNAL(clicked()), SLOT(messageLaunch()));
    5.  
    6. emitButton->installEventFilter( this );
    7. emitButton->setAutoDefault( false );
    8. emitButton->setDefault( false );
    9.  
    10. testButton->installEventFilter( this );
    11. testButton->setAutoDefault( false );
    12. testButton->setDefault( false );
    13. }
    14.  
    15. bool TestDlg::eventFilter( QObject * o, QEvent * e )
    16. {
    17. QPushButton * b = qobject_cast< QPushButton * >( o );
    18. if( b != 0 && e->type() == QEvent::KeyPress ) {
    19. QKeyEvent * ke = static_cast< QKeyEvent * >( e );
    20. if( ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return ) {
    21. b->animateClick();
    22. return true;
    23. }
    24. }
    25. return false;
    26. }
    To copy to clipboard, switch view to plain text mode 

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

    skuda (23rd November 2007)

Similar Threads

  1. Replies: 2
    Last Post: 17th May 2006, 21:01
  2. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 15:17
  3. Mouseover event on QPushButton
    By Twey in forum Newbie
    Replies: 2
    Last Post: 13th January 2006, 18:45

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.