No this is not, what I want to have.
Qt's Model/View architecture has a data() method, which provides information from the model to the view.
The data() method has different "roles" which provide different types of data to the view.
{
if (!index.isValid())
{
qDebug("DEBUG: index is not valid:");
}
if (role == Qt::DisplayRole)
return displayRole(index);
else if
(role == Qt::DecorationRole)
return decorationRole(index);
else if
(role == Qt::BackgroundRole)
return backgroundRole(index);
else if
(role == Qt::ToolTipRole)
return toolTipRole(index);
else if
(role == Qt::StatusTipRole)
{
/* if(index.row() == 0 && index.column() == 0 || index.row() == 0 && index.column() == 1)
return QVariant(" hello world");*/
}
{
// return QVariant(QIcon("arrowOpen.png"));
}
QVariant SchulungsplanModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
{
qDebug("DEBUG: index is not valid:");
return QVariant();
}
if (role == Qt::DisplayRole)
return displayRole(index);
else if
(role == Qt::DecorationRole)
return decorationRole(index);
else if
(role == Qt::BackgroundRole)
return backgroundRole(index);
else if
(role == Qt::ToolTipRole)
return toolTipRole(index);
else if
(role == Qt::StatusTipRole)
return QVariant("status");
QVariant SchulungsplanModel::displayRole(const QModelIndex &index) const
{
/* if(index.row() == 0 && index.column() == 0 || index.row() == 0 && index.column() == 1)
return QVariant(" hello world");*/
return QVariant();
}
QVariant SchulungsplanModel::decorationRole(const QModelIndex &index) const
{
// return QVariant(QIcon("arrowOpen.png"));
return QVariant();
}
To copy to clipboard, switch view to plain text mode
so the role:
(role == Qt::StatusTipRole)
return QVariant("status");
should return a String to the view, which will be presented automatically in the status bar. As far as I understand, I need not to implement some code for the representation of the status bar, it is done by the MV architecture. Am I right ? The problem is, the statusbar role seem not to work.
Bookmarks