简体   繁体   中英

How can I enumerate layouts inside layout?

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

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());
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM