[QML] Having different imports depending on Qt version
Johnny Jazeix
jazeix at gmail.com
Sat Jun 18 13:24:21 BST 2022
Hi,
for GCompris (compiled in Qt5 only), we have activities using the Calendar
qml object.
Previously, we imported the one from QtQuick.Controls 1 but this module has
been deprecated and we switched to QtQuick.Controls 2. This component
hasn't been implemented in QtQuick.Controls 2 before Qt6.3 (via "import
QtQuick.Controls").
This one is available in Qt Marketplace (
https://code.qt.io/cgit/qt-extensions/qtquickcalendar.git) and supports Qt5
and Qt 6.0-> 6.2 (via "import QtQuick.Calendar 1.0") but requires
QtControls private headers to be installed and they are not present on some
distributions (Ubuntu < 21.04...), which we would like to still support for
the next version.
There is the one in Qt.labs which is available in Qt5 but not Qt6 (via
"import Qt.labs.calendar 1.0").
GCompris' code works fine with any of the import (
https://invent.kde.org/education/gcompris/-/blob/master/src/activities/calendar/Calendar.qml#L14)
but I didn't find any "if(Qt_version < ...) use one, else the other" except
doing a Calendar.qml.cmake with a @GOOD_IMPORT@ that would be set by cmake
and a configure_file.
Is there a better way?
For now, we only target Qt5, so we could use Qt.labs without having to
handle the other two but once we switch to Qt6, we will face the issue with
distributions using Qt6.2 so I'd rather prepare this transition sooner than
later.
Cheers,
Johnny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20220618/7a42add8/attachment.htm>
More information about the kde-devel
mailing list