Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use QVector as two dimensional array?

How do I declare, initialise, and assign values to a QVector as a 2 dimensional array?

like image 506
sai Avatar asked Dec 02 '22 21:12

sai


1 Answers

The same way as a std::vector:

QVector< QVector< int > > twoDArray;      // Empty.
QVector< QVector< int > > twoDArray( 2 ); // Contains two int arrays.
twoDArray[0].resize(4);
twoDArray[0][2] = 4;  // Assign to the third element of the first array.
...
etc...
like image 51
cmannett85 Avatar answered Dec 16 '22 04:12

cmannett85