Q_INCLUDE_MOC vs Q_DECLARE_OPAQUE_POINTER
-
Hi,
whats the difference between
Q_INCLUDE_MOC
andQ_DECLARE_OPAQUE_POINTER
?
Maybe let me phrase the question in a different way:
Which one of the above is more appropriate for my usecase?
I have fordward declared classes which get used inQ_PORPERTY
and signal/slots. For that to work the types must be fully-defined, as stated inqmetatype.h
static_assert(is_complete<Pointed, void>::value, "Pointer Meta Types must either point to fully-defined types " "or be declared with Q_DECLARE_OPAQUE_POINTER(T *)");
I can get my forwarddeclared classes to be accepted by
Q_PROPERTY
and signals/slots by using either one of the above mentioned macros.
So which one should I use? -
What's
Q_INCLUDE_MOC
?
Q_DECLARE_OPAQUE_POINTER
is definitely well suited for your use case.
Its doc says:This macro enables pointers to forward-declared types (PointerType) to be registered with QMetaType [...]
-
What's
Q_INCLUDE_MOC
?
Q_DECLARE_OPAQUE_POINTER
is definitely well suited for your use case.
Its doc says:This macro enables pointers to forward-declared types (PointerType) to be registered with QMetaType [...]
@GrecKo said in Q_INCLUDE_MOC vs Q_DECLARE_OPAQUE_POINTER:
What's
Q_INCLUDE_MOC
?I meant
Q_MOC_INCLUDE
which says in the documentationThis is useful if the types you use as properties or signal/slots arguments are forward declared.
That's why I am not sure which one to use.
Since they both achieve the same for me right now, I 'd like to know what happens under the hood and which approach is more lightweight? -
I got into similar situation today, but I had to use
Q_MOC_INCLUDE
because the class is aQ_OBJECT
in my case. The Qt docs suggest thatQ_DECLARE_OPAQUE_POINTER
is incompatible in this case.Hope this helps!