QVariant: fix converting enum to string
Use QMetaEnum::valueToKey instead of valueToKeys. Change-Id: I270f0820a03aaebde94c37c011c5e9b81421b50f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
parent
18ab75be81
commit
be4f5d55fc
@ -460,7 +460,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
|
||||
{
|
||||
QMetaEnum en = metaEnumFromType(d->type);
|
||||
if (en.isValid()) {
|
||||
*str = QString::fromUtf8(en.valueToKeys(qConvertToNumber(d, ok)));
|
||||
*str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok)));
|
||||
return *ok;
|
||||
}
|
||||
}
|
||||
@ -637,7 +637,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
|
||||
{
|
||||
QMetaEnum en = metaEnumFromType(d->type);
|
||||
if (en.isValid()) {
|
||||
*ba = en.valueToKeys(qConvertToNumber(d, ok));
|
||||
*ba = en.valueToKey(qConvertToNumber(d, ok));
|
||||
return *ok;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
enum MetaEnumTest_Enum0 { MetaEnumTest_Enum0_value = 42, MetaEnsureSignedEnum0 = -1 };
|
||||
enum MetaEnumTest_Enum0 { MetaEnumTest_Enum0_dummy = 2, MetaEnumTest_Enum0_value = 42, MetaEnsureSignedEnum0 = -1 };
|
||||
Q_ENUM(MetaEnumTest_Enum0)
|
||||
enum MetaEnumTest_Enum1 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 };
|
||||
Q_ENUM(MetaEnumTest_Enum1)
|
||||
|
Loading…
Reference in New Issue
Block a user