[Qt-interest] Making a QIcon display the same pixmap it displays when it is active when selected
John Moran
johnfrederickmoran at gmail.com
Fri Feb 12 12:53:55 CET 2010
Hello,
I have an application (embedded Linux) that has a QTreeView that
displays a QStandardItemModel, some rows of which contain a QIcon in
their left-most QStandardItems.
This works fine, but I would rather not have the icons highlighted
when the row is selected (I'm happy to have the row selected, but
don't want to see the QIcon itself have that shaded blue appearance).
How can I do this?
At the moment, I give a QPixmap as the constructor argument for my
QIcon, and then subsequently add the same pixmap as an alternative
pixmap:
QIcon description_icon(icon);
description_icon.addPixmap(icon, QIcon::Selected);
This works, but seems a little inelegant. I guess the magic of
reference counting in QPixmap ought to make it efficient.
Please comment.
Regards,
John Moran
More information about the Qt-interest-old
mailing list