[Development] QML preprocessor

Jason H jhihn at gmx.com
Tue Mar 19 17:03:16 CET 2019


> On 18/03/19 12:11, Pierre-Yves Siret wrote:
> > This can be done with QQmlFileSelector :
> > 
> >     QQmlApplicationEngine engine;
> >     QQmlFileSelector* qmlFileSelector = QQmlFileSelector::get(&engine);
> > 
> > #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
> >     qmlFileSelector->setExtraSelectors({"5.12"});
> > #endif
> > 
> >     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
> > 
> > This will load qrc:/+5.12/main.qml (if there's one) instead of
> > qrc:/main.qml when the Qt version is >= 5.12.
> 
> Of all suggestions, this is probably the one having the least
> performance impact and greater readability. It still doesn't solve the
> code duplication issue (Samuel's does, but with a greater runtime
> impact), though. :-(
> 
> Anyway, thanks all!
> 
> (I'm still looking forward to see this issue addressed at the QML
> language level, though :-) )

I don't know why you can't just use a C/C++ preprocessor to generate the qml?
For Clang,   -E : Only run the preprocessor




More information about the Development mailing list