2011-07-26 134 views
1

我正在使用Qt和boost编写代码。我知道qt窗口需要在主线程开始,所以,我想在另一个线程使用boost(而不是QThread)运行一些代码。但是,如果我调用app.exec(),另一个线程(boost)停止工作,那么它将工作得很好。我不知道发生了什么,有什么线索?QT + boost-thread无法正常工作

QApplication app(argc, argv); 
QMainWindow window; 

//creating a separated thread and starting up 
boost::thread thr1(boost::bind(&X::x, &a)); 

//if we join, it works 
//thr1.joing() 

//but if I run the following lines, my thr1 freezes 
window.show(); 
app.exec(); 
+0

你如何链接升压线程?如果您静态链接,我知道Windows上有一些问题。 –

+0

我使用cmake链接,在我的CMakeLists.txt中我有 TARGET_LINK_LIBRARIES(项目$ {Boost_LIBRARIES}) 而且它起作用如果我没有启动qt = / –

回答

0

问题出在我的助推实施。我固定重新编译它