dwj
dwj

Reputation: 3483

Mixing Qt and Boost

I'm looking at starting a project in C++ using the Qt 4 framework (a cross-platform GUI is required). I've heard great things about the Boost libraries from friends and online. I've started reading up on both and wanted to ask a cursory question before I got too deep: Are these two development "systems" mutually exclusive?

My initial searching and reading shows some overlap in the signal handling, custom build systems, and other low-level primitives.

Does it make sense to use them both in the same project?

Upvotes: 66

Views: 23997

Answers (7)

user21959052
user21959052

Reputation:

No. Unfortunately this is not a good idea. Mixing types from different sources (Qt, stl, boost, some-another stl like libs) makes the code less readable. Yes, there is a need when a performance-critical section of the code does not have time to be executed, and the transition from one library to another gives the same increase in performance. But this is a very rare case. It is better to change the algorithm or code design, and not rush from one library to another.

Upvotes: 0

Özgür
Özgür

Reputation: 8247

This paper compares signal slots mechanism in QT and Boost::Signal very decently. It is a must read for those who are a bit curious of this mix.

Upvotes: 31

Tiberiu Ana
Tiberiu Ana

Reputation: 3663

Especially since you are going cross-platform, you should have a nicely layered architecture, with the business logic and data access as removed as possible from the GUI. In this case, it would make sense to use Boost when writing the backend of your application, and only jump to Qt for the frontend, with the mandatory pile of casts done in the glue.

If your "engine" is separate from your GUI choice, you will be able to swap out Qt for something else in the future (native libraries perhaps) with minimal effort.

Upvotes: 18

Martin Beckett
Martin Beckett

Reputation: 96109

Yes it makes perfect sense. I would generally prefer using the boost/stdlib functions where possible rather than their Qt alternatives.

It makes the code easier to port to the next framework.
It makes is easier for new non-Qt programmers to get upto speed.
Boost has some great functionality and is getting more all the time.

note: strings to/from widgets are probably the main exception - inside the GUI I would use Qt strings to save confusing casts everywhere.

Upvotes: 54

Pietro
Pietro

Reputation: 13164

Consider that Boost Signals2 are available, and they are thread safe.

Upvotes: 3

Daniel James
Daniel James

Reputation: 3939

There are potential problems with using Boost.Signals alongside QT. These are documented in the Boost.Signals FAQ.

Upvotes: 3

mxcl
mxcl

Reputation: 26883

We (Last.fm) use them both together, though we only just started to do so, and so haven't a good deal of experience yet. So far everything is fine though :)

Upvotes: 7

Related Questions