使用processEvents()来保持用户界面响应的例子

直接上例子吧:

//确定按钮函数
void Dialog::buttonClicked()
{
   for(int i=0; i<100; i++) {
       for(int j=0; j<10000000; j++) {
       }
       qApp>processEvents(/*QEventLoop::ExcludeUserInputEvents*/);
   }
   if (!(QMessageBox::information(this,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("确定吗?"),
                                     QString::fromLocal8Bit(""),QString::fromLocal8Bit(""))))
   {
       this->close();
   }
}

 

posted @ 2014-10-18 13:29  纠纠结结  阅读(2103)  评论(0编辑  收藏  举报