Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using Qt in non GUI application, pros and cons?

Tags:

c++

qt

I am working on a semi-realtime system using C++. Lots of the design and logic are event based. While looking for some event framework for c++, I found Qt. The signal/slot, state machine in Qt looks very good to my situation. I prefer them much more than boost. Also, the QObject system has a lot of nice features, e.g. QObject Model, moc, parent-child object memory management etc. But I know little about Qt, I have a few questions here.

  1. Giving I am pretty familiar with c++/stl now, is it worth the time to learn Qt? Anyway I will not use its most popular part, UI.

  2. What about the performance of Qt comparing to stl/boost? Since the application is realtime, performance is a key requirement. For example, I have to design the data layout very carefully to maximize the CPU cache utilization. All those features provided by Qt should bring some overhead. How much impact would that be?

  3. What about multi-threading in Qt development? Can I use stl thread or pthread with Qt objects or I have to use threading provided by Qt? Is it easy to use?

like image 980
Ryan Avatar asked Jan 28 '14 02:01

Ryan


1 Answers

  1. Qt is very worth learning. It will definitely boost up your development speed. And compared to boost framework, Qt has very complete and readable documentation and example codes which will help you to learn rapidly.

  2. I assume you're comparing the performance of the collections implementation. You can refer to this: http://blog.codeimproved.net/2009/12/qtl-or-stl/. Since Qt is more concerned about development experience, some of it's functions may have some performance drop compared to stl/boost. But if there's any major performance hit, you can always switch back to stl without pain.

  3. QThreads are built upon pthreads, while providing an OO abstraction. I suggest you to use QThread if you are working with Qt Objects. It's definitely easy to use, since development with ease is the design theory of Qt.

Another benefit of Qt is that it provides the guarantee that on every platform that supports Qt, the underlying implementation are identical, while some platform only provide incomplete or varying STL support or even no STL support at all. Qt is always more predictable, since it's managed by a single organization.

like image 169
TwilightSun Avatar answered Nov 13 '22 01:11

TwilightSun