(SOLVED) Any way to get how many widgets are in an QVBoxLayout?
-
Hi all,
I have an QVBoxLayout, where Widgets will be added at run time. When I click a button I want to print out how many Widgets are in this Layout. Is this possible? Is there an function such like getWidgets() or so?~ jan
-
Use count() to get the number of widgets.
-
@supaiku-desu (and all others)
Is there also an way to get the Name of the widget?
-
@jjan You can use itemAt to get the
QLayoutItem
at particular index and use widget to get the widget it contains. Then as usual you can useobjectName
to get the name of it. Eg:ui->verticalLayout->itemAt(1)->widget()->objectName(); //will give name of widget at index 1 //verticalLayout = QVBoxLayout
-
Many thanks!