Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Find object by name
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.
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...
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.