Results 1 to 7 of 7

Thread: spinbox ClearFocus()

  1. #1
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default spinbox ClearFocus()

    In my qt code I want to go to another page from 1st page(means I enter the number where I want to go and press enter and that page will be open). To do so I use spinBox,

    if(e->key() == Qt::Key_F)
    {
    spinBox->setFocus();
    }

    if(e->key() == Qt::Key_G)
    {
    spinBox->ClearFocus();
    }

    When I press F it set the focus of spinBox, But the problem is that when once the focus is set I can not come out from that(my Key_G is not detected).
    So please help me to come out from that focus so I can go ahead in my project.

    -Renold

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: spinbox ClearFocus()

    Since the spinbox has focus, it receives all key events so obviously your key handlers are only invoked when a particular widget has focus. To circumvent that you can install an event filter on the application object to intercept all events before they reach their targets.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: spinbox ClearFocus()

    Thanks for your reply,
    I am very new in QT.
    Can you please tell me how can I install an event filter on the application object.?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: spinbox ClearFocus()

    You can open Qt reference manual, switch to the index tab and type in "event filter".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: spinbox ClearFocus()

    Hey dear I go through Qt reference manual now I want to know that on which object I have to install event filter of my program? In function setFocus()?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: spinbox ClearFocus()

    Quote Originally Posted by RENOLD View Post
    on which object I have to install event filter of my program?
    Read my post again.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: spinbox ClearFocus()

    Thank you.... I completed it.... I am very happy....

Similar Threads

  1. a spinbox problem
    By tyhj2000 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 26th February 2010, 02:44
  2. Retaining a spinbox value
    By positive_4_life in forum Newbie
    Replies: 2
    Last Post: 19th November 2009, 17:36
  3. Getting the value from a spinbox
    By X-man in forum Newbie
    Replies: 14
    Last Post: 28th September 2007, 01:27
  4. spinbox
    By mickey in forum Newbie
    Replies: 5
    Last Post: 26th July 2006, 19:09
  5. spinbox
    By mickey in forum Newbie
    Replies: 2
    Last Post: 22nd May 2006, 08: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.