Results 1 to 5 of 5

Thread: Finding QObjcects in a qApp

  1. #1
    Join Date
    Jan 2006
    Posts
    30
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Finding QObjcects in a qApp

    In Qt 3, you can query for all of the obejcts in the qApp. This is really helpful for finding pointers to QObjects in plugins.

    How do you do this in Qt4. Whenever I run the function findChild, or any of the different versions of it the compiler says that this function doesn't exist in the QObject or qApp.

    I guess my question would be, How can I get a QObject pointer to any QObject in the qApp via a QString

    Example: If I have a plugin loaded with the name plugin_menu, I would like to be able from any function, and any plugin to be able to get a pointer to the QObject * via a string "plugin_menu"

  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: Finding QObjcects in a qApp

    Basicly you have a "findChildren" member in QObject and you can use it. But you should query plugins this way, there are other mechanisms for it. Check out QPluginLoader class.

  3. #3
    Join Date
    Jan 2006
    Posts
    30
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Finding QObjcects in a qApp

    When I call the function findChildren, the compiler says this function doesn't exist.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Finding QObjcects in a qApp

    Quote Originally Posted by rianquinn
    When I call the function findChildren, the compiler says this function doesn't exist.
    Could you post the exact error message?

  5. #5
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Finding QObjcects in a qApp

    When I call the function findChildren, the compiler says this function doesn't exist.
    Seems you're one windows using MSVC6. Check qFindChildren in the docs, findChildren is not supported my MSVC6.

    Use
    Qt Code:
    1. QWidget *objectToSearch = this;
    2. QList<QPushButton> buttons = qFindChildren<QPushButton*>( this, "nameOfObj" );
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. QWidget *objectToSearch = this;
    2. QList<QPushButton> buttons = qFindChildren( this, "nameOfObj", pb );
    To copy to clipboard, switch view to plain text mode 
    Both are untested, i wrote this from memory.

    Hope this helps.

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.