Search code examples
qtboost-thread

QT + boost-thread not working


I'm writing a code using both Qt and boost.

I know that qt window needs to be started in the main thread, so, I'm trying to run some code in another thread using boost (not QThread).

The problem is, if I run my code without starting the qt window, it works perfectly fine, however, if I call the app.exec(), the other thread (the boost one) stops working. I don't know what is happening, any clues?

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

Solution

  • the problem was with my boost implementation. I fixed recompiling it