是否可以在线程上运行主QT程序?

时间:2010-02-26 10:38:45

标签: multithreading 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();

}

1 个答案:

答案 0 :(得分:3)

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

相关问题