On Tuesday 10 September 2024 04:56:40 GMT-7 Thiago Macieira wrote: > In Qt 3, QVariant could only contain a closed set of types, so QObject:: > QObject::setProperty would only be able to write QFlags if the QVariant > contained an int, and QMetaProperty already had isEnumType() at this time > https://doc.qt.io/archives/3.3/qmetaproperty.html#isEnumType > and moc looked for functions taking or returning integers: > https://github.com/gnu-andrew/qt3/blob/master/src/moc/moc.y#L2566-L2586
Qt3-style uint accesses no longer compile:
enum Enum { E1, E2 };
Q_ENUM(Enum)
Q_PROPERTY(Enum enumValue READ enumValue WRITE setEnumValue)
uint enumValue() const { return e; }
void setEnumValue(uint v) { e = v; }
error: invalid conversion from ‘uint’ {aka ‘unsigned int’} to
‘ClassWithEnumAccessAsInteger::Enum’ [-fpermissive]
or
enum Flag { F1 = 1, F2 = 2 };
Q_DECLARE_FLAGS(Flags, Flag)
Q_PROPERTY(Flags flagsValue READ flagsValue WRITE setFlagsValue)
uint flagsValue() const { return f; }
void setFlagsValue(uint v) { f = v; }
error: ambiguous overload for ‘operator=’ (operand types are
‘ClassWithEnumAccessAsInteger::Flags’ {aka
‘QFlags<ClassWithEnumAccessAsInteger::Flag>’} and ‘uint’ {aka ‘unsigned int’})
But if you add
Q_FLAG(Flags)
(not Q_FLAG(Flag))
then it compiles... or did until my changes.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCAI Platform & System Engineering
smime.p7s
Description: S/MIME cryptographic signature
-- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
