Results 1 to 4 of 4

Thread: why triggerUpdate() is not virtual?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sofia, Bulgaria
    Posts
    24
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Zebra-like QListViewItems -- how to?

    I want to make manually drawn QListViewItems appear in "zebra-like" style, like this
    Item 1 's background is colorGroup()::base()
    Item 2 's background is colorGroup()::light()
    Item 3 's background is colorGroup()::base()
    Item 4 's background is colorGroup()::light()
    (to make rows more distinguishable)
    For a proper implementation of that I think the proper way of doing this is the following:
    Qt Code:
    1. void my_list_view::triggerUpdate() //NOTE: NOT VIRTUAL!!
    2. {
    3. int counter( 0 );
    4. for( QListViewItemIterator i( this, QListViewItemIterator::Visible ); *i; ++i, ++counter )
    5. {
    6. ( *i )->set_is_light( counter %2 );
    7. }
    8. QListView::triggerUpdate();
    9. }
    10.  
    11. my_list_view_item::paintCell( QPainter * p, const QColorGroup& cg, int colun, int width, int alignment )
    12. {
    13. QColorGroup cg2( cg );
    14. if ( is_light() )
    15. {
    16. cg2.setColor( QColorGroup::Background, cg.light() );
    17. cg2.setColor( QColorGroup::Base, cg.light() );
    18. }
    19. QListViewItem::paintCell( p, cg2, column, width, alignment );
    20. }
    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()
    How to implement such solution (or any other that may work)
    Last edited by gadnio; 11th January 2006 at 09:41.

Similar Threads

  1. Q3ScrollView resists to scroll down to the garbage bin
    By sivrisinek in forum Qt Programming
    Replies: 0
    Last Post: 5th February 2009, 17:50
  2. Cost of pure virtual
    By ShaChris23 in forum General Programming
    Replies: 4
    Last Post: 4th November 2007, 18:20
  3. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13
  4. Compiling error
    By vfernandez in forum Newbie
    Replies: 2
    Last Post: 9th March 2007, 21:02
  5. link error for visual studio.net 2003
    By berlin in forum Newbie
    Replies: 9
    Last Post: 29th September 2006, 16:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.