QMessageBox *box=new QMessageBox(this);
QTimer::singleShot(10000, box, SLOT(accept()));
QTimer::singleShot(1000, box, [box]()
{
int tt=1,t=10;
QDateTime MAspaceTime=QDateTime::currentDateTime();
bool SendTWeb;
do{
SendTWeb=(MAspaceTime.secsTo(QDateTime::currentDateTime())>10);
if (MAspaceTime.secsTo(QDateTime::currentDateTime())>=tt){
tt++;
box->setWindowTitle(tr("%1").sprintf("提示%d秒后关闭",t--));
qDebug()<<MAspaceTime.secsTo(QDateTime::currentDateTime());
if (box->isHidden()) break;
}
QApplication::processEvents();
}while(!SendTWeb);
}
);
box->setAttribute(Qt::WA_DeleteOnClose);
box->setIcon(QMessageBox::Information);
box->setWindowTitle(tr("提示10秒后关闭"));
box->setText(tr("测试计时关闭"));
box->exec();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)