How to use QVector as two dimensional array?

multidimensional-array, qt, vector

Solution

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...

Problem

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

Original source