[Interest] qt_add_qml_module() RESOURCES vs qt_add_resources()

Mike Trahearn mtrahearn at topcon.com
Sat Feb 17 00:30:27 CET 2024


I have been watching the progression of this...

Ulf is right. I've had this out with him many times inw writing and in person due to our out "strange non conforming" repository setup.
However in our case, we do not reak any of the proper QML Module boundaries so once we apply the various allowed properties of our modules to match our structure, the build system, code model, the qmlls, qmllint qmltc, qmlsc - they all work exactly as prescribed.

My first advice is this (which would also agree with Ulf): if you don't adhere to the proper QML module structure (which may I gently suggest, you haven't) then you will have these issues you describe.

________________________________
From: Interest <interest-bounces at qt-project.org> on behalf of Ulf Hermann via Interest <interest at qt-project.org>
Sent: Saturday, February 17, 2024 6:06:58 AM
To: interest at qt-project.org <interest at qt-project.org>
Subject: Re: [Interest] qt_add_qml_module() RESOURCES vs qt_add_resources()

Hi Ekke,

> not really sure what I'll have to do - will read again tomorrow and
> trying to understand ;-)
>
> BTW: this is the (qml) structure of my apps:
>
> qml/Main.qml
>      pages/MyPage.qml
>           /xxx.qml
>      popups/MyPopup.qml
>      ...

In QML these are 3 Modules:

* A module called "qml" with an addressable component "Main"

* A module called "qml.pages" with an addressable component "MyPage" and
an internal component defined in xxx.qml

* A module called "qml.popups" with an addressable component "MyPopup"

If you put all the components into the same module, and then add any
custom attributes (singleton or revision) to either MyPage or MyPopup,
you're in for a surprise: The attributes will not be applied if you use
the component from another .qml file in the same directory. For example
if you made MyPage a singleton and then used it from xxx.qml, it would
give you a confusing error message.

This is because MyPage would be imported via the implicit import of
xxx.qml, which knows nothing about the module you've declared one
directory up. The implicit import does not contain the information about
singletons.

This is why it's generally a good idea to make the implicit import the
same as the module a component belongs to.

I have understood, though, that nobody wants to follow this rule. I'll
come up with some technical solution that allows you to declare either a
module spanning multiple directories or a collection of modules, each
with its own directory. with a single CMake function call. The earliest
possible version for that to surface in is 6.8, though.

best regards,
Ulf
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://urldefense.com/v3/__https://lists.qt-project.org/listinfo/interest__;!!Nbma_1s!sg8zFNfWm_RbvERXLo9exzm2qb8Q5hC7t-EDvCALmuMaLLePXS9fWtdxeyvrXNW3sk1U6l3MAPBpBw7bprbUFg$
Confidentiality Notice: This message (including attachments) is a private communication solely for use of the intended recipient(s). If you are not the intended recipient(s) or believe you received this message in error, notify the sender immediately and then delete this message. Any other use, retention, dissemination or copying is prohibited and may be a violation of law, including the Electronic Communication Privacy Act of 1986.   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240216/f0cea370/attachment.htm>


More information about the Interest mailing list