Results 1 to 12 of 12

Thread: widget focus ---------

  1. #1
    Join Date
    Jul 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default widget focus ---------

    Hello everybody,

    my question is simple (but the answer is usually not simple). I have a widget and i need to know when this widget loose the focus. I need "some mechanism" that warn me when i loose the focus.

    thanks in advance!!

    Javi.

  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: widget focus ---------

    The answer is very simple QApplication::focusChanged().

  3. #3
    Join Date
    Jul 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: widget focus ---------

    but i have a problem with this solution, I need to know what's the next widget, but i don't know what's the next widget the user click on...??

    how focusChanged is used??

    (thanks!!)

  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: widget focus ---------

    Would you take a look at its documentation and look what parameters it has?

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

    jrodway (17th April 2008)

  6. #5
    Join Date
    Jul 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: widget focus ---------

    question answered, thanks!!

  7. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: widget focus ---------

    how can we use this signal? I mean how can we connect with the specified slot. Because it seems QApplication is not an QObject.

  8. #7
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: widget focus ---------

    Hi, use QCoreApplication::instance() or the static QApplication::qApp to get a pointer for the QApplication object.

    Ginsengelf

  9. #8
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: widget focus ---------

    Hi again,

    I 've a problem with this method. Once a new frame is poped up, the focusChange signal does not give the focus to this new widget. Therefore I should reimplement focusIn and focusOut events in this new widget. Is there a better way to do this?

    Thanks in advance

  10. #9
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: widget focus ---------

    Can anyone has any idea?

  11. #10
    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: widget focus ---------

    What exactly are you trying to achieve? Maybe QWidget::activateWindow() is something for you?
    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.


  12. #11
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: widget focus ---------

    Hi again,

    I want my widget which grabs the focus by mouse click to be raised.

    In my application, the widgets can pop-up upon a button click. Once the particular widget(Widget 1) is popped up, it is raised and may cover some part of the most recently focused widget(Widget 2) (which has just normally lowered in the widget stack).

    But when I want to raise it again by clicking on it, it grabs the focus but not raised at all. It couldn't show all of itself ( since the widget 2 covered some part of it.)

    I hope I make myself clear.

  13. #12
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: widget focus ---------

    Hi,

    Problem solved!

    The problem is in the focusing configuration of the widgets. When the ui class has a focus itself, you shouldn't set any focus to it's subwidgets.

Similar Threads

  1. Customize on focus widget
    By vql in forum Qt Programming
    Replies: 9
    Last Post: 9th April 2008, 18:58
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  3. Managing widget focus behaviour
    By mnemonic_fx in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2008, 10:27
  4. Force focus to a QTabWidget page's widget
    By thomaspu in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2008, 06:54
  5. How to get focus event in child widget
    By YuriyRusinov in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2006, 07:53

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.