遍历QT界面控件,以遍历按钮为例。
.h
public:
uInitMenu* mInitMenu = new uInitMenu();
.cpp
mInitMenu->f_Init();
int mButtonCnt = 0;
int mButtonCount = 0;
QSignalMapper *mapper = new QSignalMapper(this);
QList<QPushButton *> button = this->findChildren<QPushButton *>();
QObjectList list = children();
for(int i=0; i < button.count(); i++)//通过i的范围确定需要设置哪些button
{
QString mClassName = mInitMenu->f_GetClass("Main",button.at(i)->objectName());
if(button.at(i)->objectName().left(4)=="btn_")
{
mButtonList[mButtonCount]= button.at(i);
mButtonCount = mButtonCount + 1;
connect(button.at(i), SIGNAL(clicked()), this, SLOT(f_Style_btn()));
}
if(button.at(i)->objectName().lef