I'm trying to set different icon size for top level items of QTreeWidget. I think the way is custom QItemDelegate, but i'm not sure how to do it (delegates are a bit confusing to me). I tryed to subclass "sizeHint()", but it only affects to the item size, not to icon size:
if ( index.data(Qt::UserRole).toString() == "TopLevel1") {
return QSize(skSets.
value("SystemsTree/HIconSize").
toInt(), skSets.
value("SystemsTree/HIconSize").
toInt());
} else {
return QSize(skSets.
value("SystemsTree/IconSize").
toInt(), skSets.
value("SystemsTree/IconSize").
toInt());
}
}
QSize treeSysDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
QSettings skSets(QString("Skin/%1/Skin.ini").arg(CurrSkin), QSettings::IniFormat);
if ( index.data(Qt::UserRole).toString() == "TopLevel1") {
return QSize(skSets.value("SystemsTree/HIconSize").toInt(), skSets.value("SystemsTree/HIconSize").toInt());
} else {
return QSize(skSets.value("SystemsTree/IconSize").toInt(), skSets.value("SystemsTree/IconSize").toInt());
}
}
To copy to clipboard, switch view to plain text mode
How can i apply the sizehint to the icon?
I've noticed that the second arg ofsizeHint() is a QModelIndex, not sure if i must do a cast to QTreeWidget or something....
Hope anybody can help me.
Thanks in advance.
Bookmarks