void my_list_view::triggerUpdate() //NOTE: NOT VIRTUAL!!
{
int counter( 0 );
for( QListViewItemIterator i( this, QListViewItemIterator::Visible ); *i; ++i, ++counter )
{
( *i )->set_is_light( counter %2 );
}
}
my_list_view_item
::paintCell( QPainter * p,
const QColorGroup
& cg,
int colun,
int width,
int alignment
){
QColorGroup cg2( cg );
if ( is_light() )
{
cg2.setColor( QColorGroup::Background, cg.light() );
cg2.setColor( QColorGroup::Base, cg.light() );
}
QListViewItem::paintCell( p, cg2, column, width, alignment );
}
void my_list_view::triggerUpdate() //NOTE: NOT VIRTUAL!!
{
int counter( 0 );
for( QListViewItemIterator i( this, QListViewItemIterator::Visible ); *i; ++i, ++counter )
{
( *i )->set_is_light( counter %2 );
}
QListView::triggerUpdate();
}
my_list_view_item::paintCell( QPainter * p, const QColorGroup& cg, int colun, int width, int alignment )
{
QColorGroup cg2( cg );
if ( is_light() )
{
cg2.setColor( QColorGroup::Background, cg.light() );
cg2.setColor( QColorGroup::Base, cg.light() );
}
QListViewItem::paintCell( p, cg2, column, width, alignment );
}
To copy to clipboard, switch view to plain text mode
the "is_light" property of the item dictates weather the item is drawn with colorGroup()::base() or colourGroup()::light()
Bookmarks