C++ (Qt)void WaitingStateDialog::start(){ m_ElapsedTime.restart(); m_Timer.start(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! setWindowModality(Qt::ApplicationModal); show(); repaint(); // исходный вариант //exec();}
int main(int argv, char **argc){ QApplication app(argv, argc); QDialog le; le.show(); le.repaint(); sleep(5); // тут окна еще не видно return app.exec(); // тут уже видно}
void DecThread::sPathArc(){ QDialog dlg; Ui::pathArcDialog ui; ui.setupUi(&dlg); dlg.setFixedSize(dlg.baseSize()); if(dlg.exec() == QDialog::Accepted) { }}
class Thread: public QThread{Q_OBJECTprotected: void run() { while(true) { std::cout<<"process events"<<std::endl; QApplication::processEvents(); } }};
int main(int argc, char** argv){ QApplication app(argc, argv); Thread thread; thread.start(); QDialog dial; dial.setWindowTitle("Test"); dial.show(); sleep(15);}
C++ (Qt)#include <QtGUI> int main( int argc, char **argv ) { QApplication app(argc, argv); QDialog dlg; QLabel * lab = new QLabel("Test", &dlg); dlg.show(); while (true) { DoSomething(); QApplication::processEvents(); } return 0;}