View Full Version : alternatingRowColor
wirasto
22nd January 2010, 08:35
I tried make a custom style for my treeview with QProxyStyle. But I'm lost alternatingRowColor function. How to keep it ? Or make a new alternatingRowColor ?
Well, I tried set the alternatingrowcolor with stylesheet too. But still not working.. :cryi
aamer4yu
22nd January 2010, 11:21
What class is QProxyStyle ??
You do alternate colors in paint event of items. You can check -
if(row % 2 == 0)
// use color1
else
// use color2
wirasto
22nd January 2010, 12:18
I tried like that. But I have 3 column, and PE_PanelItemViewRow PE_PanelItemViewItem will set every cell, not every row.
QProxyStyle, check in qtdoc
numbat
22nd January 2010, 13:01
Looking in the source directory, and selecting a style at random, one finds:
if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
bool selected = vopt->state & QStyle::State_Selected;
bool hover = vopt->state & QStyle::State_MouseOver;
bool active = vopt->state & QStyle::State_Active;
if (vopt->features & QStyleOptionViewItemV2::Alternate)
painter->fillRect(vopt->rect, vopt->palette.alternateBase());
wirasto
22nd January 2010, 13:49
I can't convert QStyleOptionViewItem to QStyleOptionViewItemV4 ?
vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
my option variable is QStyleOptionViewItem. Btw, I tried in paint function on my custom delegate.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.