Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Find object by name

    General and Desktop
    3
    3
    19950
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      luca72 last edited by

      hello i have more than one progress dialog to update, and i need to find the exact one to update by object name, how i can find the correct one.

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        you can ask an object for its child by name "QObject::findChidlren":http://doc.qt.nokia.com/4.7/qobject.html#findChildren

        This works for children of a widget als (as widgets are qobjects) and only if the objects have names "QObject::setObjectNames":http://doc.qt.nokia.com/4.7/qobject.html#objectName-prop

        From my point it would be easier to use member variables though, as you then have pointers to the objects. If you don't know how many you will have at design time, create maps to store the pointers. It will make life easier...

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

          As an alternative approach, consider using signals and slots instead of directly updating your values. This way, you don't need to care about the name or keep maps with pointers around. You just make sure your progress dialog is connected to the right set of signals from whatever is progressing.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post