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?
Qt's moc (Meta Object Compiler) provides a clean way to go beyond the compiled language's facilities. It does so by generating additional C++ code which can be compiled by any standard C++ compiler.
The Meta-Object Compiler, moc , is the program that handles Qt's C++ extensions. The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes.
The Boost. Signals library is an implementation of a managed signals and slots system. Signals represent callbacks with multiple targets, and are also called publishers or events in similar systems.
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
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With