Results 1 to 4 of 4

Thread: 2 Dimensional array in QML

  1. #1
    Join Date
    Aug 2012
    Posts
    23
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default 2 Dimensional array in QML

    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
    Qt Code:
    1. Rectangle {
    2.  
    3. width: 400
    4. height: 400
    5. color: "#d5b9b9"
    6. id:rect
    7. property variant signalStrings: []
    8. signal handledSignal(variant array)
    9. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. var temp = rect.signalStrings
    2. temp[temp.length] = "onSignal_object1"
    3. temp[temp.length] = "onSignal_object2"
    4. temp[temp.length] = "onSignal_object3"
    5. temp[temp.length] = "onSignal_object4"
    6. rect.signalStrings = temp
    7. rect.handledSignal(signalStrings)
    To copy to clipboard, switch view to plain text mode 

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

    Thanks in advance....

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 2 Dimensional array in QML

    There is no such thing as a two dimensional array in C++ (nor in JavaScript/QML).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2012
    Posts
    23
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: 2 Dimensional array in QML

    Ok, thank you..
    Can I do it as a list of variant property?
    What I tried is
    Qt Code:
    1. property variant signalStrings: {'signal':"",'CAN':"",'PGN':"",'Bitpos':""}
    2. property list<signalStrings>signalList:[signalStrings{signal:"ss";CAN:"aa";PGN:"jjj";Bitpos:"ww"}]
    To copy to clipboard, switch view to plain text mode 
    but it causes some errors.. (signalStrings is not a valid property type)
    Please suggest a suitable way...

    Thanks in advance......
    Last edited by nestuser; 5th October 2012 at 05:40.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 2 Dimensional array in QML

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Operations in 2 dimensional array
    By Stanfillirenfro in forum Qt Programming
    Replies: 4
    Last Post: 5th August 2012, 16:50
  2. Replies: 2
    Last Post: 18th December 2011, 23:34
  3. QwtPolar: Plot using a 2-dimensional array
    By hgstoehr in forum Newbie
    Replies: 0
    Last Post: 14th December 2011, 21:39
  4. Multi-dimensional objects array
    By matulik in forum Newbie
    Replies: 3
    Last Post: 23rd October 2011, 02:20
  5. use QVector as 2 dimensional Array
    By umulingu in forum Qt Programming
    Replies: 3
    Last Post: 1st January 2010, 12:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.