Like we have preprocessor directives in C++ for conditional includes.
Similarly, how to do conditional importing in QML?
import
if x import ABC 1.0 else import PQR 2.0
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.
Loader { source: condition?"RedRectangle.qml":"BlueRectangle.qml" }
1.4m articles
1.4m replys
5 comments
57.0k users