tags:

views:

448

answers:

3

I know they can be used together, but I'm wondering whether it's possible to replace Qt's signals and slots mechanism with Boost.Signal in the Qt parts of the program (widgets and such).

Anyone ever try it? Any gotchas?

Assuming I don't use any other MOC features and replace signals/slots with boost.signal, is it possible to do without moc entirely?

+1  A: 

I don't think that is something you want to do. Qt's signals are deeply integrated in the framework and how they are generated and handled. Don't waste your time :)

fabrizioM
+2  A: 

I considered it for one of my projects. One aspect that might bother you, depending on the project is the use of Qt Designer. The Qt-Designer creates signal-slots underneath for its GUI connections. So, if you happen to use the designer, you will end up with projects having both signals-slots and boost::signals. There are some issues with using them together f.e. see this blog. Though its possible for them to work together, i would refrain from mixing the two approaches.

But the biggest problem i faced was that boost::signals are not thread-safe whereas Qt's signal-slot is! So it was easy decision for me as my project was multithreaded.

You can get the relative merits and de-merits of the approach taken by boost and Qt from Page-11 of this PDF.

HTH

Abhay
Boost.Signals2 is thread safe. And I'm not using Qt Designer, so that wouldn't be a problem.
drby
@drby: What about you build? Is it automated to use the *MOC* macro using qmake? If yes, you may have to change that as well. If not, then i would prefer boost anytime, simply because it is more typesafe. Good luck.
Abhay
A: 

Mixing Qt and Boost

Comptrol