1.程序重启
void Widget::reStart()
{
qApp->closeAllWindows();
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
}
2.遍历布局中的控件
int count= ui->verticalLayout->count();
for(int i=;i<count;i++)
{
QLayoutItem *it= ui->verticalLayout->itemAt(i);
QPushButton *button=qobject_cast<QPushButton*>(it->widget());
if(button!=NULL)
{
button->setText("button1");
}
}
3. 程序中让程序等待时间执行
QEventLoop eventloop;
QTimer::singleShot(, &eventloop, SLOT(quit()));
eventloop.exec();