[Interest] what are the requirements for QMetaType::metaObjectForType(QMetaType::type("QQuickLayout*")) to work?

Ulf Hermann ulf.hermann at qt.io
Mon May 6 20:12:55 CEST 2024


On 5/6/24 18:12, NIkolai Marchenko wrote:
> Is there a way to automatically import qtquick.layouts while importing a 
> custom module inside of qml file?

If you control the custom module and are OK with anyone importing the 
custom module always also importing QtQuick.Layouts, then yes. There is 
IMPORTS in qt_add_qml_module(), see 
https://doc.qt.io/qt-6/qt-add-qml-module.html#declaring-module-dependencies

If you are using Qt5, you are probably writing your qmldir files 
manually. In that case, there is the "import" declaration: 
https://doc.qt.io/qt-6/qtqml-modules-qmldir.html#module-import-declaration

The latter also exists in Qt 5.15 even though it's only documented for Qt6.

best regards,
Ulf


More information about the Interest mailing list