QT + boost-thread无效

时间:2011-07-26 02:34:54

标签: qt boost-thread

我正在使用Qt和boost编写代码。

我知道qt window 需要在主线程中启动,所以,我试图使用boost(而不是QThread)在另一个线程中运行一些代码。

问题是,如果我在没有启动qt窗口的情况下运行我的代码,它可以正常工作,但是,如果我调用app.exec(),则另一个线程(boost 1)停止工作。我不知道发生了什么,有什么线索吗?

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();

1 个答案:

答案 0 :(得分:0)

问题在于我的提升实施。我修复了重新编译它