Reputation: 1844
Does it make sense to use Qt for increasing the productivity in an MFC app, without actually using the Qt user interface system?
I am currently looking or a good productivity library for my MFC based application, with useful container classes, string algorithmus, threading classes, I/O classes and so on. The Qt API is very nice in my opinion. However, since I don't want to switch my UI to Qt (just too much effort), I am wondering whether Qt can be used well in a MFC app without any Qt UI.
Thanks in advance for your opinions.
Fabian
Upvotes: 7
Views: 6362
Reputation: 756
Qt is divided into several modules (QtGui being one of them). You can hand pick which modules are used by your application by linking only against the libraries you need.
I cannot answer whether Qt will be interopable with MFC. But at the very least, QString offers conversion to std::string and char*/wchar, which should help you quite a bit.
The Qt documentation provides an overview over the modules.
As daniel pointed out below, you have to be aware of the event loop. It is possible however to use the event loop without the GUI module. You can call processEvents on QCoreApplication to process all queued events and then return. There is one caveat with deferred deletions, but the documentation describes the workaround.
Upvotes: 11
Reputation: 185
Sure, you can use QT toolkit without using it's GUI library.
Depending on your needs, you might want to consider boost libraries which provides a sane set of APIs that helps for many things. I personally use it for doing network sockets in a multi-platform way, but there is a lot more in it.
Upvotes: 5
Reputation: 28892
There are some utility classes that you can use but there is a very important caveat. Qt depends very heavily on its event loop. The event loop is started by calling QApplication::exec()
. Now many Qt classes depend on the signals and slots mechanism is Qt. Signals and slots are totally dependent on the event loop to function correctly.
This is totally true for the GUI modules but is also true of some of the other modules. One can expect every class derived from QObject
to use signals and slots and will therefore be unusable without the event loop.
Upvotes: 7
Reputation: 4808
yes you can, you have just to exclude QtGui Module from your project (.pro) because it included by default.
QT -= gui
like this the Core Module only is used.
Upvotes: 3
Reputation: 28268
The Mumble project uses Qt for the client and server, with the server not having any UI code at all, still using the rest of the Qt API extensively.
Upvotes: 2
Reputation: 96109
If you only want it for the collection classes why not just use std:: library?
Upvotes: 0