Normally, you implement your own data() method that returns the value for a given ModelIndex. It could look something like this:
{
if (!index.
isValid()) return QVariant();
if (role == Qt::TextAlignmentRole)
{
... alignment code ...
}
if (role == Qt::DisplayRole)
{
*** This is where you should check the state of your dynamic items ***
... return data for requested item ...
}
}
QVariant CalculatorTapeModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) return QVariant();
if (role == Qt::TextAlignmentRole)
{
... alignment code ...
}
if (role == Qt::DisplayRole)
{
*** This is where you should check the state of your dynamic items ***
... return data for requested item ...
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks