using QML, Qt5QuickControls2_jll
function get_int()
return 1
end
function QML.loadqml(text::QByteArray; kwargs...)
qml_engine = init_qmlengine()
ctx = root_context(QML.CxxRef(qml_engine))
for (key,value) in kwargs
set_context_property(ctx, String(key), value)
end
component = QQmlComponent(qml_engine)
QML.set_data(component, text, QUrl())
create(component, qmlcontext())
return component
end
text = QByteArray("""
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.julialang 1.0
ApplicationWindow {
visible: true
Timer {
running: true
onTriggered: {
var int_val = Julia.get_int()
console.log(typeof int_val, int_val)
Qt.quit()
}
}
}
""")
@qmlfunction(get_int,send_int)
loadqml(text)
exec()
On Windows we get
Qt Debug: number 1 (:11, onTriggered)
On Linux we get
Qt Debug: object 1 (:11, onTriggered)
After using such a number with object type it sometimes becomes an empty object {} resulting in an error. Floats and strings do not have such an issue.
Here is a minimal reproducible example.
On Windows we get
On Linux we get
After using such a number with object type it sometimes becomes an empty object
{}
resulting in an error. Floats and strings do not have such an issue.