Results 1 to 5 of 5

Thread: Is there a way to know the current widget of the app ?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Is there a way to know the current widget of the app ?

    I would want to know if I can determine in a Class_B who is the active or current widget of my application.
    By other side, supposing my app is showing a form, any way to know the 'toplevel' parent ?
    Thanks

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Is there a way to know the current widget of the app ?

    If by active you mean the widget which receives user input, than you have hasFocus()
    And QObject has (QWidget is derived from it so it has this too) parent() member function which returns a pointer to the parent object.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Is there a way to know the current widget of the app ?

    You can also have a look at QApplication::focusWidget().

  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: Is there a way to know the current widget of the app ?

    Quote Originally Posted by tonnot View Post
    any way to know the 'toplevel' parent ?
    QWidget::window()
    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
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there a way to know the current widget of the app ?

    Thanks to everybody

Similar Threads

  1. Add style to current
    By mstegehu in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2010, 09:51
  2. QTabWidget: how to force "no current widget"?
    By mattc in forum Qt Programming
    Replies: 4
    Last Post: 13th May 2009, 12:18
  3. Get current ip address
    By Trok in forum Qt Programming
    Replies: 5
    Last Post: 16th March 2009, 23:08
  4. Getting Current Directory.
    By afflictedd2 in forum Qt Programming
    Replies: 2
    Last Post: 16th November 2008, 22:27
  5. getting current Id from tableView
    By mkarakaplan in forum Newbie
    Replies: 3
    Last Post: 7th October 2007, 22:14

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.