Like we have preprocessor directives in C++ for conditional includes.
Similarly, how to do conditional import
ing in QML?
if x
import ABC 1.0
else
import PQR 2.0
Like we have preprocessor directives in C++ for conditional includes.
Similarly, how to do conditional import
ing in QML?
if x
import ABC 1.0
else
import PQR 2.0
extending a little bit the @Yoann answer:
where ABC.qml :
and PQR.qml :
or if don't what to have real qml files you can create them at runtime with:
Depending on what you want to achieve, a possible workaround is to use a Loader. But it does not import a module, it just allows to choose dynamically which QML component you'll use.