如何枚举布局内的布局?
How can I enumerate layouts inside layout?
我可以枚举布局内的小部件,但我需要在布局内枚举布局内的小部件...
我正在尝试:
while (QHBoxLayout* currentLayout = m_Layout->findChild<QHBoxLayout*>()) {
while (QCheckBox* currentCheckbox = currentLayout->findChild<QCheckBox*>()) {
if (currentCheckbox->isChecked()) {
}
}
}
但是这段代码卡住了...我想这可能是因为我找不到 QHBoxLayout,还有其他可能的方法可以枚举布局内的布局吗?
谢谢
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());
}
}
我可以枚举布局内的小部件,但我需要在布局内枚举布局内的小部件...
我正在尝试:
while (QHBoxLayout* currentLayout = m_Layout->findChild<QHBoxLayout*>()) {
while (QCheckBox* currentCheckbox = currentLayout->findChild<QCheckBox*>()) {
if (currentCheckbox->isChecked()) {
}
}
}
但是这段代码卡住了...我想这可能是因为我找不到 QHBoxLayout,还有其他可能的方法可以枚举布局内的布局吗?
谢谢
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());
}
}