[Interest] Problems with qt_add_qml_module

Stefan Seefeld stefan at seefeld.name
Tue Oct 24 15:36:16 CEST 2023


Hi Ulf,

thank you for following up !

Yes, it's entirely possible I'm missing something fundamental, trying to
approach a problem from the wrong side, so let me give some context:

We are developing an application that's written mostly in C++ with a GUI
done in QML. The application architecture is fairly complex, so we tried to
modularize it as much as possible. At the heart is an application
"skeleton" that would set up the basic services (including a QML
Application Engine), into which additional components are loaded. The
skeleton app would load a `main.qml` file that defines a few Loader
instances, which would eventually load additional QML items at runtime.
Most of the context would be injected into the QML runtime from C++ via
calls to `setContextProperty()`, as well as by defining additional QML
modules from C++ (via `qmlRegister...()`).

So far we use C++ unit tests that would load particular QML items
individually and then run some checks from C++.

The above setup implies that the QML modules are very dependent on the C++
context, and as a result, cannot be loaded by stand-alone QML tools,
including and in particular things like `qmltestrunner`.
Thus, I would like to define some QML "extension modules" such that I can
load them into QML as standalone tools (prototypes, unit tests, etc.).

Does the above make sense ? Is this an appropriate use of extension modules
? Are there other ways to do what I want ?

Now let me follow up to some technical details:


Now, the specific exceptions are run time style selection for
> QtQuick.Controls and image providers. If you are affected by those, you
> should set NO_GENERATE_PLUGIN_SOURCE, NO_PLUGIN_OPTIONAL, and explicitly
> specify PLUGIN_TARGET and CLASS_NAME. Then you can use target_sources on
> the generated plugin target to add your own implementation of the
> specified plugin class. Be aware that you need to manually reference
> some symbols from the backing library in order to prevent the linker
> from "optimizing" the dependency away.
>

I tried that, but the linking of my plugin library failed due to unresolved
symbols. I tried to specify additional libraries using
`target_link_libraries()` which resulted in the cmake error I reported
earlier.


 Thanks,

-- 

      ...ich hab' noch einen Koffer in Berlin...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231024/82517069/attachment.htm>


More information about the Interest mailing list