2010-02-26 104 views
1

我有一个简单的QT对象。当我执行下面的代码时,控制权转移给QT对象,但是我想让QT部分像线程一样工作。是否可以在线程上运行主QT程序?

int main(int argc, char *args[]) 
{ 
    gui *GUI; 
    //// before call 

    QApplication app(argc,args); 
    GUI = new gui();  
    GUI->show(); 

////i want to be able to do stuff here in parallel with the QT code. 
// If I spawn a thead here or give a simple printf statement here 
// or before call it executes only after GUI exits 

return app.exec(); 

} 

回答

2

确保您不仅创建线程,而且实际启动它。另外,除非您忘记用换行符(\n)终止字符串,否则将在GUI显示之前执行printf()语句。

相关问题