遍历控件

今天试着实现代码遍历Layout中的空间,百度and Google了一下,试了几遍,以下是我的做法:

QList<QGroupBox*> lstgroupBox = this->findChildren<QGroupBox*>();
    for(int i = 0; i < lstgroupBox.count(); i++ )
    {
        foreach(QObject* objbutton, lstgroupBox[i]->children())
        {
            btn = qobject_cast<QPushButton*>(objbutton);
            if(btn)
                connect(btn, SIGNAL(clicked()), this, SLOT(slot1()));
        }
    }

 

posted @ 2013-05-12 14:30  wiessharling  阅读(205)  评论(0编辑  收藏  举报