[Development] Why does QFlag exist? (Not QFlags)
Thiago Macieira
thiago.macieira at intel.com
Tue Sep 10 13:56:40 CEST 2024
On Monday 9 September 2024 23:00:28 GMT-7 Eirik Aavitsland via Development
wrote:
> No idea if this is helpful, but it seems that what was later renamed
> QFlag was introduced as QFlagInternal in this commit:
Thank you Aavit. Did already QFlags have the enum_type typedef in this commit?
What I find interesting is the code it generated for the getter prior to this
change:
fprintf(out, " case %d: *(%s*)_v = %s();
break;\n",
propindex,
- !isVariantType(p->type) ? "int" : (const
isVariantType was still present in 4.x and was renamed to isBuiltinType prior
to 5.0 and is still there. Enums are usually not built-in types[*], so this
meant that it would always expect that the array contain a pointer to an
integer. The question is why.
Another question: did QVariant in this commit already have userType()?
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
[*] there is one built-in enum in QVariant/QMetaType today, QCborSimpleType. I
do remember needing to do something extra to add this built-in type compared
to the norm.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240910/c5ed115c/attachment.bin>
More information about the Development
mailing list