[SOLVED] StandardItemModel and appendRow() clarifications
-
Hi, I am making a table by using QStandardItemModel which will contain 3 rows and 1 column. Then I add items by using the appendRow() function. My questions are the following:
What happens if I add a 4th item to the model via the appendRow function?
The model does not accept it?
Items already in the model are deleted?Thanks.
-
A "constructor description":https://qt-project.org/doc/qt-5/qstandarditemmodel.html#QStandardItemModel-2 says
"Constructs a new item model that initially has rows rows and columns columns"
It means that the model will be expanded on "demand":https://qt-project.org/doc/qt-5/qstandarditemmodel.html#appendRow -
Hi andreyc, thanks but I don't see where the doc is saying what you are saying. In addition what type of structure is "rows rows and columns columns"? I mean how does it look like? To finish you say that the model will be expanded on demand? From which demand? Mine?! Its own?! If it is mine how can it finally constructs a new item model if I do not demand it? Sorry but it really confuses me.
-
[quote author="amonR" date="1400333726"]Hi andreyc, thanks but I don't see where the doc is saying what you are saying. In addition what type of structure is "rows rows and columns columns"? I mean how does it look like? [/quote]
Have you looked at the doc that is under link in my previous message, the constructor contains three parameters, numR, numC, and parent
@
QStandardItemModel::QStandardItemModel(int numR, int numC, QObject * parent = 0)
@
I renamed first two and parent is not important for us. So the description says:
"Constructs a new item model that initially has numR rows and numC columns, and that has the given parent."I think it means that you can provide an initial numbers for rows and columns and then as you add more rows or columns the model will grow.
[quote author="amonR" date="1400333726"]
To finish you say that the model will be expanded on demand? From which demand? Mine?! Its own?! If it is mine how can it finally constructs a new item model if I do not demand it? Sorry but it really confuses me.[/quote]If an application logic will require the model to keep more rows and columns that it was initially specified then the model will grow.
So, if you are the creator of the application then the model will grow on your demand. :-)Bottom line, you can append as many rows and columns as you need until all memory is used. The model will keep them all.
Best way to prove it is the simple test application. -
Sorry for insisting but it still not clear for me and I still don't have answers to my first questions.
You said:"Bottom line, you can append as many rows and columns as you need until all memory is used. The model will keep them all."
Can I append more rows and colums once their numbers are already set? Yes or no how Qt reacts? Does it take into account or not a new append attempt if all colums and rows are full? And which memory are you talking about?
Please let me know if my questions are not clear, because I am repeting them now. -
[quote author="amonR" date="1400455086"]Can I append more rows and colums once their numbers are already set? Yes or no[/quote]Yes.
[quote author="amonR" date="1400455086"] how Qt reacts?[/quote]It will expand an internal storage to keep old and new records
[quote author="amonR" date="1400455086"] Does it take into account or not a new append attempt if all colums and rows are full?[/quote]It does take into account if all columns and rows are full.
[quote author="amonR" date="1400455086"]And which memory are you talking about?[/quote]I was talking about "RAM":http://en.wikipedia.org/wiki/Random-access_memory
[quote author="amonR" date="1400455086"]Please let me know if my questions are not clear, because I am repeting them now.[/quote]I think your questions are pretty clear.