support both Qt5 and Qt6

This commit is contained in:
pls.153 2022-01-25 14:41:35 +01:00
parent 07f5fd05a0
commit 4440c06e70
6 changed files with 21 additions and 11 deletions

View file

@ -1,6 +1,6 @@
import QtQuick import QtQuick 2.13
import QtQuick.Controls import QtQuick.Controls 2.13
import Lisp import Lisp 1.0
Rectangle { Rectangle {
width: 220 width: 220

View file

@ -2,29 +2,29 @@
WIP WIP
--- ---
Currently Linux/macOS/desktop only, will be extended to all platforms Currently Linux/macOS/desktop only, will be extended to mobile; not sure about
(including mobile); not so sure about Windows though... Windows though.
Description Description
----------- -----------
A lightweight ECL based QML-only binding to Qt6. A lightweight ECL based QML-only binding to Qt5/Qt6.
License License
------- -------
Both ECL and Qt6 are LGPL. ECL and Qt5/Qt6 are LGPL.
LQML can be considered public domain. LQML can be considered public domain.
TODO TODO
---- ----
* port to CMake
* make example work on android * make example work on android
* make example work on iOS * make example work on iOS
* add item model example * add item model example
* add sokoban example * add sokoban example
* port to CMake

View file

@ -127,7 +127,11 @@ cl_object qset2(cl_object l_obj, cl_object l_args) {
var = toInt(l_val); var = toInt(l_val);
} }
else { else {
#if QT_VERSION < 0x060000
var = toQVariant(l_val, mp.type());
#else
var = toQVariant(l_val, mp.typeId()); var = toQVariant(l_val, mp.typeId());
#endif
} }
if (!mp.write(qobject, var)) { if (!mp.write(qobject, var)) {
goto fail; goto fail;

View file

@ -80,7 +80,11 @@ int main(int argc, char* argv[]) {
bool slime = false; bool slime = false;
if (arguments.contains("-slime") if (arguments.contains("-slime")
#if QT_VERSION < 0x060000
|| (arguments.indexOf(QRegularExpression::wildcardToRegularExpression("*start-swank*.lisp")) != -1)) {
#else
|| (arguments.indexOf(QRegularExpression::fromWildcard(QString("*start-swank*.lisp"))) != -1)) { || (arguments.indexOf(QRegularExpression::fromWildcard(QString("*start-swank*.lisp"))) != -1)) {
#endif
arguments.removeAll("-slime"); arguments.removeAll("-slime");
slime = true; slime = true;
} }

View file

@ -225,7 +225,11 @@ TO_CL_FLOAT_4 (QRectF, qrectf, x, y, width, height)
cl_object from_qvariant(const QVariant& var) { cl_object from_qvariant(const QVariant& var) {
cl_object l_obj = ECL_NIL; cl_object l_obj = ECL_NIL;
#if QT_VERSION < 0x060000
const int type = var.type();
#else
const int type = var.typeId(); const int type = var.typeId();
#endif
switch (type) { switch (type) {
case QMetaType::Bool: l_obj = var.toBool() ? ECL_T : ECL_NIL; break; case QMetaType::Bool: l_obj = var.toBool() ? ECL_T : ECL_NIL; break;
case QMetaType::Double: l_obj = ecl_make_doublefloat(var.toDouble()); break; case QMetaType::Double: l_obj = ecl_make_doublefloat(var.toDouble()); break;

View file

@ -51,7 +51,5 @@ SOURCES += \
cpp/qt_ecl.cpp \ cpp/qt_ecl.cpp \
cpp/main.cpp cpp/main.cpp
clang { QMAKE_CXXFLAGS += -std=c++17
QMAKE_CXXFLAGS += -std=c++17
}