[Interest] [Qt6] QML_ATTACHED failing with ::QQmlPrivate not declared
Konstantin Shegunov
kshegunov at gmail.com
Sun Jan 2 07:26:25 CET 2022
Hello,
I've been doing some experimenting with Qt6's QML - C++ integration
(qtdeclarative @ 3d23912b0e, following the docs on providing attached
properties for a QML exposed class and I'd got the aforementioned compile
error.
I have the C++ class(es) in a dynamic library where in the CMakeLists.txt
I've added the absolute minimum:
qt_add_qml_module(TscCore
URI TscCore
VERSION ${TSC_VERSION}
)
The code which causes the error is very bare-bones; it basically
follows the documentation's examples. The classes are in a namespace,
but I don't believe that's the actual cause for the error.
Here's a very condensed snippet of the declarations:
#include <QtQml/qqmlregistration.h>
TSC_BEGIN_NAMESPACE
class TSCCORE_API SimulationAttachedType : public QObject
{
Q_OBJECT
QML_ANONYMOUS
public:
... };
class TSCCORE_API Simulation : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Simulation)
QML_ATTACHED(SimulationAttachedType)
QML_UNCREATABLE("")
QML_NAMED_ELEMENT(Simulation)
... };
TSC_END_NAMESPACE
With a bit of sifting through the headers the error goes away if I include
QtQml/qqmlprivate.h. After that the integration part works just fine, the
objects are available and the attached properties accessible.
So, did I stumble on a bug?
Kind regards,
Konstantin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220102/408139cb/attachment.htm>
More information about the Interest
mailing list