How do I declare, initialise, and assign values to a QVector
as a 2 dimensional array?
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With