[Development] Metatype system in Qt6

d3fault d3faultdotxbe at gmail.com
Thu Dec 5 21:19:40 CET 2019


On 12/5/19, Olivier Goffart <olivier at woboq.com> wrote:
> That will not be working anymore if the MyType is only worward declared.
> The user will have to do one of these:
>   1. #include "MyType.h"  in the header
>   2. Q_DECLARE_OPAQUE_POINTER(MyType *)
>   3. Q_MOC_INCLUDE("MyType.h") : that's not yet implemented but would make
> moc
> include the file in the generated file.
>

>
> Now another question is what exactly do we want to automatically register.
> Of course, we will register the way to construct, copy, and destruct the
> types.
> Now, should we also register automatically the other things that we can do:
>
>   - operator==
>   - QDataStream operators
>   - QDebug operator
>
> Ideally we also want this to be automatic, but i've run into an issue.
> I naively tought it would be simple enough to just use SFINAE to detect if
> the
> type has the operator==, with something like that.
>


If qt6-moc depends on libclang [0], we could intelligently determine
that MyType* is only forward declared and then transparently generate
the required calls to Q_DECLARE_OPAQUE_POINTER(MyType*) where needed.
Same goes for detecting ==operator/QDataStream/QDebug. I've heard
Thiago say that depending on libclang is a no go [1]. Is this no
longer the case for Qt6? Having libclang available during the
precompile stages would open up a world of possibilities for Qt.

d3fault

[0] - https://wiki.qt.io/Qt_Contributors_Summit_2019_-_moc_and_QMetaObject
[1] - https://bugreports.qt.io/browse/QTBUG-68589?focusedCommentId=406466&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-406466


More information about the Development mailing list