2011-07-26 63 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

問題出在我的助推實施。我固定重新編譯它