PDA

View Full Version : Pushbutton in delegate with icon - left margin problem



Talei
14th July 2011, 01:10
Hello,
I have a problem with painting pushbutton with icon in delegate. The problem is that when I pain Icon with pushbutton left margin/"left position value" is set to 0 = left side of the column in view, but when I don't paint Icon everything is good and I can set left margin to some other value i.e. 10 (with is equal to left value of the CE_PushButton).
The painting looks like this:

QStyleOptionButton pb_Style;
pb_Style.state = option.state;
pb_Style.rect = option.rect;
// pb_Style.icon = QIcon( ":/icon.png" );
// pb_Style.iconSize = QSize( 12, 12 );

/** when Icon is drawn delegate calculate wrong left pos with is equal to the row left */
QApplication::style()->drawControl( QStyle::CE_PushButton, &pb_Style, painter );

The result is this: 6660 , icon is painted all the way to the left row pos, but what I want is to paint it to left pos of the pushbutton (CE_PushButton).
The problem is probably that I don't pas rect for the Icon properly but...

Thanks for any help

Talei
15th July 2011, 06:49
Maybe I wasn't clear enough, icon is painted (when resizing) way back to 0 pos (relative to row left pos = 0 pos of icon) but CE_PushButton maintain left margin (i.e. 10 pixels) so what You see in above image is after resizing column.
Any suggestions are more then welcome because I struggle with this for a long time.