Find object by name
-
wrote on 22 Mar 2011, 08:10 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.
-
wrote on 22 Mar 2011, 08:40 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...
-
wrote on 22 Mar 2011, 09:06 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/3