Hands-On High Performance Programming with Qt 5
上QQ阅读APP看书,第一时间看更新

Using Qt containers

Let's start with the statement that there's a raging debate when it comes to Qt data structures. There are proponents of Qt data structures and in the opposite camp the champions of standard STL algorithms and data structures.

What can we say about that? Qt containers were designed long ago when some platforms didn't support STL. The design objectives were for them to be good enough for GUI programming, easy to use, and discoverable, whereas STL containers were designed to be general-purpose, efficient, and correct. Thus, Qt containers lack many features of their STL counterparts and they also were neither modernized nor have they acquired many new features since the times of Qt 4. They are just good enough to build GUIs. As they are used pervasively in all Qt APIs, it would be a performance sin to copy their data to STL containers only to be able to use a better implementation.

So, we have to cope with them and be wary of their limitations and performance profiles. For that reason, we will discuss the things to watch out for when using Qt data structures.