PDA

View Full Version : How to set the decoration hightlighted when select a row in QTreeView



lovehouye
5th July 2011, 04:10
Hello,

I want to hightlight the whole row when select it in QTreeView.
But it seems the decoration (+) never highlighted.
I want it works like the followed picture. But it isn't the windows style.
I have try to use: show-decoration-selected: 1; but it's not helpful.
I also tried setAllColumnsShowFocus ( true ) , also can't work.

6629

Can somebody help me about this?

lovehouye
6th July 2011, 06:03
I use delegate to draw the rows.
In paint function:


if( option.state & QStyle::State_Selected )
{
QRect rect( option.rect );
rect.setLeft( 0 );
painter->fillRect( rect, option.palette.highlight() );
}


For this, all the area can be highlighted. But overwritted decoration can't be shown. Maybe the color of decoration should be changed when selected.