How can I enumerate layouts inside layout?

52 views Asked by At

I can enumerate widgets inside layout but I need to enumerate widgets inside layouts inside layout...

I'm trying:

  while (QHBoxLayout* currentLayout = m_Layout->findChild<QHBoxLayout*>()) {
    while (QCheckBox* currentCheckbox = currentLayout->findChild<QCheckBox*>()) {
      if (currentCheckbox->isChecked()) {

      }
    }
  }

But this code just stucks... I guess it's maybe because I can't find QHBoxLayout, is there other possible ways I can enumerate layout inside layouts?

Thank you

1

There are 1 answers

0
Amartel On BEST ANSWER
for (int i = 0; i < layout->count(); ++i) {
    QLayoutItem *item = layout->itemAt(i);
    if (item->widget()) {
        processWidget(item->widget());
    } else if (item->layout()) {
        processLayout(item->layout());
    }
}