diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 620e6d57a83..aa0b4fc2998 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1945,11 +1945,19 @@ static bool convertFromEnum(QMetaType fromType, const void *from, QMetaType toTy #ifndef QT_NO_QOBJECT QMetaEnum en = metaEnumFromType(fromType); if (en.isValid()) { - const char *key = en.valueToKey(ll); - if (toType.id() == QMetaType::QString) - *static_cast(to) = QString::fromUtf8(key); - else - *static_cast(to) = key; + if (en.isFlag()) { + const QByteArray keys = en.valueToKeys(ll); + if (toType.id() == QMetaType::QString) + *static_cast(to) = QString::fromUtf8(keys); + else + *static_cast(to) = keys; + } else { + const char *key = en.valueToKey(ll); + if (toType.id() == QMetaType::QString) + *static_cast(to) = QString::fromUtf8(key); + else + *static_cast(to) = key; + } return true; } #endif diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index aa88fd0ea8e..5f2ce689188 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -4753,6 +4753,8 @@ void tst_QVariant::metaEnums() testVariantMeta(Qt::RichText, &ok, "RichText"); testVariantMeta(Qt::Alignment(Qt::AlignBottom), &ok, "AlignBottom"); + testVariantMeta(Qt::Alignment(Qt::AlignHCenter | Qt::AlignBottom), &ok, + "AlignHCenter|AlignBottom"); } void tst_QVariant::nullConvert()