On Wednesday 16 of July 2014 06:37:25 Ziller Eike wrote: > [...] > > When one use QVariant, it is because we want to enjoy dynamic typing and > > nice conversions. > > > 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. > Even if automatic conversion might be interesting (when, actually?), then > the point is: > There is no API in QVariant to support the common use case of getting the > value *without* automatic conversion.
Nobody asked for it, It should be easy to implement something equal to this; Q_ASSUME(variant.userType() == qMetaType<TargetType>()); TargetType data = variant.value<TargetType>(); I believe such new api make sense, we can add it. > > >>> We use common sense on a case by case basic. > > > > Either there is no “common sense” common to me, or this rule has failed in > the past already ;) > bool -> string ? > bytearray -> int/long/double ? > keysequence -> int ? > string -> bool ? > string -> bytearray ? > string -> int ? > > Br, Eike What is wrong with string -> int or bytearray -> int? > -- > Eike Ziller, Senior Software Engineer - Digia, Qt > Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin > Geschäftsführer: Mika Pälsi, Juha Varelius, Anja Wasenius > Sitz der Gesellschaft: Berlin. Registergericht: Amtsgericht Charlottenburg, > HRB 144331 B > _______________________________________________ > Development mailing list > Development@qt-project.org > http://lists.qt-project.org/mailman/listinfo/development _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development