开发者

Use Boost.Signal instead of Qt's signals? Do without moc?

开发者 https://www.devze.com 2022-12-17 00:34 出处:网络
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 a开发者_运维知识库nd

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 a开发者_运维知识库nd 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?


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号