An array is not meant to behave like an array. Of course there are some solutions.
I found a solution that seems to approach what you want, see if it helps. It shows how to initialize the vector as if it were a matrix.
There is a class in Qt for this but it was considered obsolete and as far as I know nothing was created to replace it. but it has a more modern class in version 4.6 onwards.
Another obvious option is to look for a class that serves you in another library. It might not be as simple to integrate with Qt.
There is still the possibility of creating a class of your own that works as a matrix. This can bring some advantages of integration with Qt depending on how you do it.
I found a gambit in that reply in the OS:
int index(int x, int y) {
return x + width * y;
}
So you simulate a matrix within the vector:
QVector<...> vector(width * height);
vector[index(5, 3)] = ...;
I put in the Github for future reference.
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero