[Development] QML preprocessor

Alberto Mardegan mardy at users.sourceforge.net
Sun Mar 17 13:34:09 CET 2019


Hi there!
  When developing a QML module for the greater public one wants to
provide a source package that can be built on multiple Qt versions.
However, QML's lack of a preprocessor makes this rather cumbersome.

Suppose that my module needs to provide an element like this:

====
import QtQuick 2.10

Item {
    ...
    Flickable {
        boundsMovement: Flickable.StopAtBounds
        ...
    }
}
====

If I wanted to make this available to users of Qt 5.9 and older, I'd
need to ship another file, instead, importing QtQuick 2.9 and removing
that "boundsMovement" property.

Keeping two or more copies of the same file and installing the proper
one depending on the Qt version is certainly doable, but it carries a
considerable maintenance cost.

I've personally decided to keep a single copy of each QML file but use
different git branches; however, this also has its maintenance costs and
makes things harder for people using the project, in that they need to
checkout the right branch of the project, otherwise it won't work on
their machines.

Has this problem been recognized and discussed before? Would a QML
preprocessor be a viable option?
I understand that this is not a problem for Qt itself, and it's a minor
problem for app developers; however, developing a portable QML module
depending on QtQuick is nearly impossible due to this, unless one agrees
to settle on a certain old version of Qt and renounce to all the goodies
that were added in later versions.

Ciao,
  Alberto



More information about the Development mailing list