Problem trying to create a QString matrix
-
Hello, I have created a model in which I wish items to be editable and I want to store items such as:
private: int rows=0; int columns=5; int count = 1; QString m_gridData[rows][columns];
in m_gridData are stored the values, but in my class I need the number of rows and columns to be dynamic since I add rows during execution time but this QString matrix need cols and rows not to be a class variables and it needs const int values...How can I to make this matrix size editable as I am running my app.
Thanks!
-
Hi,
Something like a
QVector<QVector<QString>>
? -
Yes, by doing:
QVector<QVector<QString> > *m_gridData = new QVector<QVector<QString> >;
But how do I add values from data into rows and column?
What I want is to store data written in a tableview column editable into this matrix and I don't know how to do it.Thanks
-
@jss193 said in Problem trying to create a QString matrix:
But how do I add values from data into rows and column?
m_gridData[row][col] = "some string";
If m_gridData really has to be a pointer (does it?):
(*m_gridData)[row][col] = "some string";
-
There's usually no need to allocate your vector on the heap. Why do you need that ?