16,239
社区成员
发帖
与我相关
我的任务
分享
t *ttt;
QObjectList qol = this->children();
bool hasc = false;
qDebug() << qol.count();
for (int i = 0; i < qol.count(); i++) {
QObject *o = qol[i];
QString name = o->objectName();
qDebug() << name;
if (name == "ttt") {
hasc = true;
break;
}
}
if (!hasc) {
ttt = new t();
}
ui.label->setNum(qol.count());
ttt->show();
从qol.count()看,children()不包含新创建的“ttt”