PDA

View Full Version : 2 Dimensional array in QML



nestuser
4th October 2012, 12:14
Hi,
I want to send a signal with an array argument from QML to CPP. I did it using 1 dimensional array.
my sample code is


Rectangle {

width: 400
height: 400
color: "#d5b9b9"
id:rect
property variant signalStrings: []
signal handledSignal(variant array)
}




var temp = rect.signalStrings
temp[temp.length] = "onSignal_object1"
temp[temp.length] = "onSignal_object2"
temp[temp.length] = "onSignal_object3"
temp[temp.length] = "onSignal_object4"
rect.signalStrings = temp
rect.handledSignal(signalStrings)


Now I want to send a two dimensional array. How can I do it?

Thanks in advance....

wysota
4th October 2012, 20:01
There is no such thing as a two dimensional array in C++ (nor in JavaScript/QML).

nestuser
5th October 2012, 05:17
Ok, thank you..
Can I do it as a list of variant property?
What I tried is


property variant signalStrings: {'signal':"",'CAN':"",'PGN':"",'Bitpos':""}
property list<signalStrings>signalList:[signalStrings{signal:"ss";CAN:"aa";PGN:"jjj";Bitpos:"ww"}]

but it causes some errors.. :( (signalStrings is not a valid property type)
Please suggest a suitable way...

Thanks in advance......

wysota
5th October 2012, 07:38
As I said, there is no such thing as a two dimensional array. You are still dealing with a one dimensional array so you can do it exactly the same way as before. Only that an element of each array is another array.