Results 1 to 3 of 3

Thread: Key filtering

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Key filtering

    Hi Everyone,
    I'm trying to filterout key press event in text edit. If i press enter key then all the datas from text edit need to be erased. Below is my code. If right side Enter key of keyboard is working fine, but it left Enter key(Entre key above Shift key) is not filtering, i mean i'm not getting the warrning messagebox, Please tell how to filter out.

    bool eventFilter(QObject *obj, QEvent *event)
    {
    if(event->type() == QEvent::KeyPress)
    {
    QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);

    int iKeyVal = keyEvent->key();
    if(keyEvent->key() == Qt::Key_Enter)
    {
    // Do some work
    QMessageBox::warnig(DISPLAY WARNING);
    }
    }
    }
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Key filtering

    one is the enter key, the other is return key.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    phillip_Qt (24th June 2010)

  4. #3
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Key filtering

    Qt::Key_Return

  5. The following user says thank you to borisbn for this useful post:

    phillip_Qt (24th June 2010)

Similar Threads

  1. Filtering QSqlQueryModel
    By mourad in forum Qt Programming
    Replies: 4
    Last Post: 2nd August 2009, 09:32
  2. Event Filtering on Widgets
    By QbelcorT in forum Newbie
    Replies: 1
    Last Post: 28th November 2008, 21:27
  3. filtering a TreeView from buttom to top
    By soul_rebel in forum Qt Programming
    Replies: 11
    Last Post: 23rd April 2008, 07:15
  4. Filtering a TreeWidget
    By soul_rebel in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2008, 20:08
  5. Filtering as Excel in Table
    By ankurjain in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2006, 09:05

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.