QtCore vs C++ STL & boost lib: overview

copyright (C) qingfeng Xia 2011-2020 CC-BY-NC 4.0

QtCore vs C++ STL & boost lib

Author: Qingfeng Xia
Date: March 05 2013

since most of the content is from documentation or forum threads, it can be regards as same license as QT documentation.  Most of text are copied from internet, reference to original link, I just organized them into sub topics: I did not spend much to retouch the text and grammer, so it will not suitable to be copied into your report or thesis (joking!).


QtCore has cover a wide range of  C standard lib/C++ standard lib,  but you still can use the standard C/C++ lib.   For example, threading is newly added into C++11, but is already in QtCore: QRunnable QMutex  QThread (not in QtConcurrent, usage is more or less like python and Java). <qglobal>  includes a lot of Macros  (e.g.  qint64, no need for <stdint.h>  ) , Q_ASSERT for C++11 static_assert.  Even, there are
<qmath qnumeric  qlocale qendian>.

This article focuses on Qt5 only, as it is mentioned C++11 is prerequisit for QT5 see: http://www.macieira.org/blog/2011/09/cxx11-support-in-qt-5/
It is not clear, that lambda will be allows in QT slot?

C++11 is still lacking the type system information, boost seems improve it on this topics.  The metadata of QObject is the basis of QT lib.  Reading and understanding QObject and all classes in QtCore before go through this series.  For example,  QFlag is more powerful than enuml it supports bit “and or xor” operation.  see “KDAB contributions to Qt 5.0 (part 1 – 4)” http://www.kdab.com/kdab-contributions-to-qt-5-0-part-4/

On the other hand,  there are some merits in C++11 that are abscent in QtCore. C++ <algorithm> is a good companian to STL containters, while QtAlgorithm is available for Qt 4.8 (in Qt5.0 it is recommended to use STL algorithm).  C++ has <function> (function as a class and lambda) and <functional>, but C++ function can not be used as slot of QT!!! (http://stackoverflow.com/questions/9922005/using-any-c-function-as-a-qt-slot)

Personallly, I recommended to use QtCore utility as much as possible, e.g. using QFile instead of STL stream <fstream> for style compatible, and QString for itis power.

(1) IO
(2) STL container (important!  QVector is recommended over QList)
(3) Threading ()
(4) smart pointers (table comparison)
(5) slot and signal ( C++11 in QT5)
(6) boost filesystem and QDir QFile programming notes
(7) serialization boost vs Qt
(8) Boost.Variant vs. Boost.Any  QVariant

CC-BY-NC 4.0 licensed free for non-commercial usage
Author: Qingfeng XIA
copyright (C) 2011-2020
please keep the original link in your reference.
This entry was posted in Uncategorized. Bookmark the permalink.