Results 1 to 5 of 5

Thread: alternatingRowColor

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question alternatingRowColor

    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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: alternatingRowColor

    What class is QProxyStyle ??
    You do alternate colors in paint event of items. You can check -
    Qt Code:
    1. if(row % 2 == 0)
    2. // use color1
    3. else
    4. // use color2
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: alternatingRowColor

    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

  4. #4
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: alternatingRowColor

    Looking in the source directory, and selecting a style at random, one finds:
    Qt Code:
    1. if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
    2. bool selected = vopt->state & QStyle::State_Selected;
    3. bool hover = vopt->state & QStyle::State_MouseOver;
    4. bool active = vopt->state & QStyle::State_Active;
    5.  
    6. if (vopt->features & QStyleOptionViewItemV2::Alternate)
    7. painter->fillRect(vopt->rect, vopt->palette.alternateBase());
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to numbat for this useful post:

    wirasto (22nd January 2010)

  6. #5
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Smile Re: alternatingRowColor

    I can't convert QStyleOptionViewItem to QStyleOptionViewItemV4 ?


    Qt Code:
    1. vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
    To copy to clipboard, switch view to plain text mode 

    my option variable is QStyleOptionViewItem. Btw, I tried in paint function on my custom delegate.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.