
Originally Posted by
anda_skoa
Why don't you create and calculate in C++ directly?
This question does not make much sense to me.
I have a GUI designed in QML. User is supposed to fill in some values there.
I am supposed to calculate something from those values and then pass them to C++ so that they can be used
in an algorithm.
You think this kind of problem cannot exist in a properly designed program?
Anyways,
I have found a temporary solution as follows:
One way to add the values dynamically to a 1 dimensional QML variant is to fill a normal Javascript array and then assign it to the QML variant.
import QtQuick 2.0
Rectangle
{
property variant oneDArray: []
MouseArea
{
anchors.fill: parent
onClicked:
{
var t = new Array (0)
t.push(11)
t.push(12)
oneDArray = t
console.log (oneDArray)
}
}
}
import QtQuick 2.0
Rectangle
{
property variant oneDArray: []
MouseArea
{
anchors.fill: parent
onClicked:
{
var t = new Array (0)
t.push(11)
t.push(12)
oneDArray = t
console.log (oneDArray)
}
}
}
To copy to clipboard, switch view to plain text mode
Output:
Starting /home/.../documents/test/build-junk-Desktop_Qt_5_1_0_GCC_64bit-Debug/junk...
QML debugging is enabled. Only use this in a safe environment.
[11,12]
/home/.../documents/test/build-junk-Desktop_Qt_5_1_0_GCC_64bit-Debug/junk exited with code 0
Starting /home/.../documents/test/build-junk-Desktop_Qt_5_1_0_GCC_64bit-Debug/junk...
QML debugging is enabled. Only use this in a safe environment.
[11,12]
/home/.../documents/test/build-junk-Desktop_Qt_5_1_0_GCC_64bit-Debug/junk exited with code 0
To copy to clipboard, switch view to plain text mode
Bookmarks