PDA

View Full Version : Status Bar - StatusTipRole



starcontrol
30th April 2008, 11:56
Hi,

I tried to use the StatusBar feature in my Model/View application by selecting the right role in my data() method:

if (role == Qt::StatusTipRole)
return QVariant("Hello World");

but nothing happens :-/ Do I have to activate the status bar in my main window ? Or what is my mistake ?

Thanks for your help,
Alex

aamer4yu
30th April 2008, 21:43
I am sorry, I didnt get what you want to achieve.

If you want to display message in the status bar,
u can use - statusBar()->showMessage() method in the QMainWindow class of ur application.

starcontrol
2nd May 2008, 10:00
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.



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();
}


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.

starcontrol
5th May 2008, 13:56
nobody who can help ?

jpn
12th May 2008, 23:19
Which exact version of Qt are you using? Try:


view->viewport()->setMouseTracking(true);