What is your build system ? QMake or CMake ?

Instead of qmlRegisterType you should use QML_ELEMENT
see https://t1p.de/ekkeQML_ELEMENT

ekke

Am 31.08.24 um 21:23 schrieb Dirk Hohndel via Interest:

Hi there,

I've been trying to figure out how to port a QML app from Qt5 to Qt6 and have been unable to solve what seems like a fairly basic issue.

In the Qt5 version, I was able to make a class available from C++ by simply calling

...
qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile)
...

in the C++ code and then using

import org.subsurfacedivelog.mobile

in the QML file in order to then be able to use that type as

QMLProfile {
...
}

in the QML code.

When I try this code unmodified, it compiles fine, but at run time tells me that it cannot find the org.subsurfacedivelog.mobile module when it encounters that import org.subsurfacedivelog.mobile line.

So I tried some searching and found several pages in the Qt6 documentation that all seem to imply that this isn't how things should be done in Qt6 and that instead I would need to go down the route of defining a separate QML module with its own compile unit (is this true? why would you disable this core feature???)

And then trying to do that, I fail to get the module to compile with missing include paths. If it turns out that that's the only way to go, I'll happily give a lot more details on this issue -- but I'd love to first get back to the previous approach. Is there still a way in Qt6 to register a Type with QML without having to create separate modules?

Thanks

/D

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to