diff --git a/doc/help.htm b/doc/help.htm
index 4ddaf8f..5191e1e 100644
--- a/doc/help.htm
+++ b/doc/help.htm
@@ -49,6 +49,13 @@
like in a QML Repeater.
+hex (number)
+
+ Meant for passing NUMBER to QML/JS, where we only have floats. The number is
+ stored as a hex string in QML, and automatically converted back to a number
+ when passed with 'Lisp.call()'.
+
+
pixel-ratio ()
Returns the effective device pixel ratio.
diff --git a/src/cpp/lqml.cpp b/src/cpp/lqml.cpp
index 7fc4269..b471a96 100644
--- a/src/cpp/lqml.cpp
+++ b/src/cpp/lqml.cpp
@@ -7,7 +7,7 @@
#include
#include
-const char LQML::version[] = "23.9.1"; // September 2023
+const char LQML::version[] = "23.9.2"; // September 2023
extern "C" void ini_LQML(cl_object);
diff --git a/src/cpp/qml_ext.cpp b/src/cpp/qml_ext.cpp
index c8b4605..be6a4f5 100644
--- a/src/cpp/qml_ext.cpp
+++ b/src/cpp/qml_ext.cpp
@@ -20,11 +20,16 @@ static QVariant toVariant(const QJSValue& value) {
#else
const int type = var.typeId();
#endif
- if (type == QMetaType::Double) {
- // workaround for uint32, see '>>>0' in QML
- quint32 uint = var.toUInt();
- if (uint == var.toDouble()) {
- return QVariant(uint);
+ if (type == QMetaType::QString) {
+ QString s(var.toString());
+ // numbers passed with '(qml:hex number)' to QML (and stored there as
+ // strings) are automatically converted back to a number (qint64).
+ if (s.startsWith("#x")) {
+ bool ok;
+ qint64 num = s.mid(2).toLongLong(&ok, 16);
+ if (ok) {
+ return QVariant(num);
+ }
}
}
return var;
diff --git a/src/lisp/package.lisp b/src/lisp/package.lisp
index 59a6a91..c992f66 100644
--- a/src/lisp/package.lisp
+++ b/src/lisp/package.lisp
@@ -13,6 +13,7 @@
#:disable-clipboard-menu
#:ensure-permissions
#:find-quick-item
+ #:hex
#:pixel-ratio
#:qapropos
#:qapropos*
diff --git a/src/lisp/qml.lisp b/src/lisp/qml.lisp
index edca0dc..a04f83f 100644
--- a/src/lisp/qml.lisp
+++ b/src/lisp/qml.lisp
@@ -14,6 +14,14 @@
pkg))
(find-symbol upper))))
+(defun hex (number)
+ "args: (number)
+ Meant for passing NUMBER to QML/JS, where we only have floats. The number is
+ stored as a hex string in QML, and automatically converted back to a number
+ when passed with 'Lisp.call()'."
+ (let ((*print-base* 16))
+ (x:cc "#x" (princ-to-string number))))
+
;;; function calls from QML
(defun qml-apply (caller function arguments)