[Development] Converting types in Qt
Jędrzej Nowacki
jedrzej.nowacki at digia.com
Wed Jul 16 13:30:14 CEST 2014
On Wednesday 16 of July 2014 06:37:25 Ziller Eike wrote:
> I don’t think we have a single place in Qt Creator where we want automatic
> conversions when using QVariant. A search for QVariant(Map) returns 5400
> hits. In the map case, we usually expect the one retrieving the value for a
> key to know the exact type of what was thrown in (that’s usually the same
> class, or related classes), and then we use item models and QSettings which
> we use in the same way.
>From performance point of view it is good to avoid any conversions. I would
say even more, if you know all types in your application there is no point in
using QVariant. Sometimes it is not possible, and sometimes one just don't
want be bothered.
I made an extremely unfair experiment. I switched off all conversions in Qt
and I recompiled QtCreator. To be honest I expected that it would crash at
startup, but no (impressive!). I was able to use menu and open dialogs,
nothing more. From the stderr I could deduct that a QVariant conversion was
used in reading xml, qws files and in animations.
Cheers,
Jędrek
More information about the Development
mailing list