Hello!
I am new to Qt and hope you can help me. I am trying to write a simple application for invoice and customer management.
The situation is:
Header-File:
...
...
...
QAbstractItemModel *model;
...
To copy to clipboard, switch view to plain text mode
CPP-File:
...
...
...
model = new QStandardItemModel(modelSizeRow, modelSizeColumn, this);
...
To copy to clipboard, switch view to plain text mode
Now I was trying to populate a table with
model
->setData
(model
->index
(row, counter,
QModelIndex()), pieces.
value(counter
));
model->setData(model->index(row, counter, QModelIndex()), pieces.value(counter));
To copy to clipboard, switch view to plain text mode
So far everything works fine. But after some reading I thought that populating the model with QStandardItem might be a better idea. (Is this right?)
model->setItem(row, counter, item);
QStandardItem *item = new QStandardItem(QString(pieces.value(counter)));
model->setItem(row, counter, item);
To copy to clipboard, switch view to plain text mode
This does not work, I get the following message.
class QAbstractItemModel has no member named setItem
Can someone tell me why? I am confused by the following code:
...
...
...
...
QAbstractItemModel *model;
...
model = new QStandardItemModel(modelSizeRow, modelSizeColumn, this);
...
To copy to clipboard, switch view to plain text mode
What happens if a type is set to a different type using the keyword new? Is this possible if the objects are related by inheritance?
Thanks in advance!
Kind regards,
HomeR
Bookmarks