0

我有一个窗户。当我按下一个按钮时,它会执行一个功能。该功能在某些时候可能会启动另一个窗口。在那个窗口中,用户可以做一些事情。当那个窗口打开时,我没有使用另一个窗口。

所以这是我试图实现的目标:

try {
 this->hide();
 vector<ICD11> postcoordinations = dbhandler->QueryHasPostcoords(temp,ICD11cluster);
 if(!postcoordinations.empty()){
  ClusterPostcoordination *cp = new 
  ClusterPostcoordination(nullptr,&temp,&postcoordinations,&ICD11cluster);
  cp->show();
  QEventLoop loop;
  cp->connect(cp, SIGNAL(destroyed()),  &loop, SLOT(quit));
  loop.exec();
  }
 this->show();
}  catch (exception &e) {
 qDebug() << e.what();
}

我正在使用QEventLoop在第二个窗口打开时执行它的操作。一旦我关闭另一个窗口,第一个窗口会弹出一秒钟,并在完成当前功能后关闭。我希望它完成当前功能,然后继续显示窗口,以便可以用它完成其他事情。try-catch 块不捕获任何东西。可能是什么问题,我该如何解决?还是有更好的方法让我让主线程在继续之前等待另一个窗口完成?

4

0 回答 0