Results 1 to 9 of 9

Thread: 2D array in Qt: QVector or QList

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default 2D array in Qt: QVector or QList

    Hi,

    I need to store strings in a 2D array (table). Example:

    car train bike
    boat car scooter
    bus ship shuttle

    What is the best way to do it (I don't use GUI, it's a console application)? QVector or QList?
    Does anyone have instructions for declaring and constructing a 2D array of strings? The contents (but not the size) of the 2D array changes a lot during the runtime.

    Is this an acceptable way:
    Qt Code:
    1. QVector<QString> *array[3];
    2. for(i=0; i<3; i++) {array[i] = new QVector<QString>(3);}
    To copy to clipboard, switch view to plain text mode 

    But then how do I fill this with data. This did not work:

    Qt Code:
    1. array[0][0]="hello";
    To copy to clipboard, switch view to plain text mode 

    Thanks!
    Last edited by timmu; 18th May 2012 at 10:47.

Similar Threads

  1. extracting QVectors from a multidimensional QVEctor array
    By OzQTNoob in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2012, 07:45
  2. QVector array declear
    By zhxys in forum Newbie
    Replies: 8
    Last Post: 2nd February 2011, 09:17
  3. Replies: 1
    Last Post: 4th August 2010, 17:13
  4. use QVector as 2 dimensional Array
    By umulingu in forum Qt Programming
    Replies: 3
    Last Post: 1st January 2010, 12:31
  5. QVector crashes when array size is big
    By Sheng in forum Qt Programming
    Replies: 49
    Last Post: 27th February 2009, 22:13

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.