Qt application not working with qrc prefixes

670 views Asked by At

I think I'm missing some fundamental way of working with various prefixes in the Qt Creator qrc environment.

If I place a qml component in the default prefix, the application builds and runs fine. But if I add a new prefix and then add a new component with this new prefix, the application output tells me it is not a type when I run the app (it builds without error).

Qt Creator recognizes it when it is assigned a different prefix, and I can work with it in the IDE. It shows up in the qrc editor & it becomes a component that I can select within 'Designer'. It also builds without problem... but when I run my application, the application output tells me it is not a type.

If I then open qrc editor and move that component to the default prefix, the application will then run fine.

It seems like I've not given it the direction to find the component at runtime when it is assigned to an alternative prefix.

I'm at a loss as to where I would direct the application to the other prefixes.

I've tried using the "import" in the component that I wish to use it in without success. I've tried giving it an alias without success.

What needs to happen for this component to be recognized in my app as a type... even though it's already recognized within Qt-Creator?

If it's a prefix, it seems I should add it as a prefix to something I can type in; where would that be?

1

There are 1 answers

0
Steve H On

I was able to solve my problem with a syntax adjustment.

If a qml file wants to use a qml component from a different qml file that is listed in the qrc under a different prefix, it must import the prefix.

I was trying this without success: import "/myOtherPrefix"

However, it needs it to be like this: import "qrc:/myOtherPrefix"

I was not able to find a reference for this in the Qt documentation (it's probably there somewhere)