[Development] Circular dependencies for Q_PROPERTY
Mike Krus
mike.krus at kdab.com
Mon Apr 27 12:14:09 CEST 2020
Hi Simon
yes that worked, didn’t know about Q_MOC_INCLUDE
Thanks!
PS: seems Creator’s syntax highlighter doesn’t know about it either :)
> On 27 Apr 2020, at 11:08, Simon Hausmann <Simon.Hausmann at qt.io> wrote:
>
> Hi,
>
> I think the solution may involve keeping forward-declarations but adding visibility to the "other" types in moc generated code by using Q_MOC_INCLUDE in A to include B and vice versa. Does that make sense?
>
>
> Simon
> From: Development <development-bounces at qt-project.org> on behalf of Mike Krus via Development <development at qt-project.org>
> Sent: Monday, April 27, 2020 11:52
> To: Qt Development Group <development at qt-project.org>
> Subject: [Development] Circular dependencies for Q_PROPERTY
>
> Hi
>
> I have 2 classes, A and B, derived from QObject, each have a property
> of type pointer-to-other-class. So
>
> class A : public QObject {
> Q_PROPERTY(B *foo …)
> …
> };
>
> And:
>
> class B : public QObject {
> Q_PROPERTY(A *foo …)
> …
> };
>
> Because of the circular dependency, I can’t #include the full class
> definition, just do forward declaration.
>
> Now this fails in Qt 6, seems the moc generated code needs the
> full class declaration.
>
> Looking at generated moc code, looks like creating the meta object
> requires a qt_metaTypeArray<A*, bool> which checks that A derives
> from QObject by calling IsPointerToTypeDerivedFromQObject
> which uses sizeof() which requires the full type.
>
> Any way around this? Seems like a rather big regression compared
> to Qt 5…
>
>
> Mike
>
> —
> Mike Krus | mike.krus at kdab.com | Senior Software Engineer
> KDAB (UK) Ltd., a KDAB Group company
> Tel: UK Office +44 1625 809908 Mobile +44 7833 491941
> KDAB - The Qt Experts, C++, OpenGL Experts
—
Mike Krus | mike.krus at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel: UK Office +44 1625 809908 Mobile +44 7833 491941
KDAB - The Qt Experts, C++, OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4193 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200427/f3703a2c/attachment-0001.bin>
More information about the Development
mailing list