PDA

View Full Version : About QTreeView's shadow.



yangyunzhao
17th August 2009, 05:23
Hi,all

In my program,I use Treevew.At the front of each Item,there's a icon.
When you click one item,there will be a shadow.Work as follow:
http://www.qtcentre.org/forum/attachment.php?attachmentid=3572&stc=1&d=1250479239

But I want it works as follow.I hope the shadow do not cover the icon.
http://www.qtcentre.org/forum/attachment.php?attachmentid=3573&stc=1&d=1250479239

Could you give me some helps?Thanks a lot!

aamer4yu
17th August 2009, 20:34
You can try using delegates..
In QItemDelegate, there is a method drawDecoration. To this function you pass a set of option. You can modify those option and set it as unselected so that the blue background is not drawn...

Am not sure how to do it with QStyledItemDelegate. but it must be something similar :)

faldzip
18th August 2009, 00:12
You can implement your own paint() method in delegate where you can use QStyle obtained by QApplication::style() to draw the item view's item background with QStyle::drawPrimitive() with QStyle::PE_PanelItemViewItem where you can pass modified QStyleOption, in your case with modified rect.
Didn't try but it has chance to work :]

yangyunzhao
19th August 2009, 09:52
You can implement your own paint() method in delegate where you can use QStyle obtained by QApplication::style() to draw the item view's item background with QStyle::drawPrimitive() with QStyle::PE_PanelItemViewItem where you can pass modified QStyleOption, in your case with modified rect.
Didn't try but it has chance to work :]

Thanks to all replies!!!

I follow your tips,but has no evolution.
Could you give me more helps, more details?
Thanks a lot!!!