How do you get a widget’s children in Qt?

You can use the findChild() function with the object name to get a specific child.

You can also use findChildren() to get all the children that have the same name and then iterate through the list using foreach() or QListIterator.

To get a button you can try:

QPushButton* button = pWin->findChild<QPushButton*>("Button name");

Leave a Comment