Hi, I’m trying to make a light UI with QML but I didn’t find the way to call Julia functions from QML with a vector as parameter and to use this vector in Julia. This example calls the Julia function fct1
when a button, opened in a window, is pressed.
In julia :
using QML
using Qt5QuickControls_jll
using Qt5QuickControls2_jll
function fct1(var1)
println(typeof(var1))
println(var1)
println(var1[1])
end
@qmlfunction fct1
loadqml("returnVector.qml")
exec()
In qml :
import QtQuick 2.2
import QtQuick.Dialogs 1.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.0
import org.julialang 1.0
ApplicationWindow {
id: appWindow
visible: true
Item {
id: cst
property var vect1: [0,0.5,1]
}
Button {
//Layout.alignment: Qt.AlignCenter
text: qsTr("click")
onClicked: { Julia.fct1(cst.vect1) }
}
}
I obtain a vector of type QVariant[QVariant of type Int32 with value 0, ...]
and I didn’t find a way to transform it in a usable form in Julia. And I’m not even able to say if I’m completely wrong or if it’s just a little trick.
If someone has an idea, or could explain what precautions we have to take to pass from QML world to Julia world, I’m very interested
Thanks !