Results 1 to 4 of 4

Thread: prob with keyPressEvent()

  1. #1
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default prob with keyPressEvent()

    Dear Friends,
    I need to filter Esc key in Dialogs, i had reimplemented keyPressEvent(QKeyEvent *) just below,
    but its not working


    Qt Code:
    1. void myCLass::keyPressEvent(QKeyEvent *e)
    2. {
    3. if(e->key()==Qt::Key_Escape)
    4. {
    5. e->ignore();
    6. }
    7. else
    8. {
    9. QDialog::keyPressEvent(e);
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    i have set Focus Policy in my dialog object
    Qt Code:
    1. win = new QDialog(this);
    2. win->setFocusPolicy(Qt::StrongFocus);
    To copy to clipboard, switch view to plain text mode 

    can any body help me t o fix this problem

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: prob with keyPressEvent()

    I think you should reimplement QDialog::reject.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Sep 2009
    Posts
    54
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: prob with keyPressEvent()

    Quote Originally Posted by spirit View Post
    I think you should reimplement QDialog::reject.
    can u tell how ....?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: prob with keyPressEvent()

    Qt Code:
    1. ...
    2. void MyDialog::reject()
    3. {
    4. //do something...
    5. }
    6. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Prob in designing inbox
    By Askar in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2009, 14:08
  2. Replies: 21
    Last Post: 6th October 2009, 15:06
  3. prob with QFile and QTextStream class
    By bajarangi in forum Newbie
    Replies: 0
    Last Post: 27th June 2009, 00:57
  4. QToolbar in Window Vista prob.
    By patrick772goh in forum Qt Programming
    Replies: 3
    Last Post: 20th August 2007, 10:35
  5. installation prob qt4.3 commercial with msvc2005
    By omprakash in forum Installation and Deployment
    Replies: 4
    Last Post: 18th July 2007, 15:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.