[Interest] Qt containers deprecated with 5.0?

André Somers andre at familiesomers.nl
Mon Nov 28 10:54:54 CET 2016


Hi,


Op 27/11/2016 om 18:32 schreef Bob Hood:
> This is probably common knowledge, but I came across the following 
> paragraph sited in a stackoverflow answer[1] from a page regarding Qt 
> algorithms[2]:
>
> "Historically, Qt used to provide functions which were direct 
> equivalents of many STL algorithmic functions. Starting with Qt 5.0, 
> you are instead encouraged to use directly the implementations 
> available in the STL; most of the Qt ones have been deprecated 
> (although they are still available to keep the old code compiling)."
>
> The responder then summarizes:
>
> "So using STL when programming with Qt 5 is officially encouraged, 
> should it become a necessity."
>
> The original poster was asking about tuples, but the responder sites 
> Qt algorithms.  My question is:  Were Qt containers also deprecated 
> along with Qt algorithms starting with Qt 5.0?  Or put another way, 
> should new code based on the Qt5 series avoid using Qt-specific 
> containers now?

As an addition to the answers already received earlier: there is nothing 
wrong with using std containers in a Qt application, and std containers 
are even used inside Qt nowadays. They are not on the API surface 
though, and that's where it starts to hurt a bit. If you end up needing 
Qt API that takes/returns containers regulary but use std containers in 
the surrounding code, you will be doing lots of quite useless 
conversions/copies. That results in ugly and slow performance.

There is nothing wrong with using Qt containers either (with the 
exception of QList, which you will want to stear clear of as much as you 
can), as as noted, you can (and should) use the std algorithms on them 
just fine.

André




More information about the Interest mailing list