View Full Version : How to change some files backgroundcolors
tkms
15th December 2008, 06:33
I want to change the backgroundcolor, that some files in treeview.
but, I don't know how to change.
spirit
15th December 2008, 06:50
QVariant MyTreeModel::data(const QModelIndex &index, int role) const
{
....
if (role == Qt::BackgroundRole)
return QColor(lightGray);
....
}
tkms
17th December 2008, 04:12
I want to add a color to the parent of the file which I chose. how should I do it?
spirit
17th December 2008, 06:23
use this method
bool QAbstractItemModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
i.e. in you case
...
QVariant v = QColor(Qt::red);
myModel->setData(index, v, Qt::BackgroundRole);
...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.