Results 1 to 3 of 3

Thread: Qt4.7.0 Alternate Row Color from QSS ignored (QTreeView)

  1. #1
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt4.7.0 Alternate Row Color from QSS ignored (QTreeView)

    I've run into a strange behavior when changing from Qt 4.6.3 to 4.7.0, and I'm not sure what the culprit is.

    I'm only beginner-intermediate with Qt, so it's very likely some misunderstanding about how all the moving parts interact.

    I have specified the following in my QSS file:
    Qt Code:
    1. background-color: #FFFFFF;
    2. border-color: #C3C3C4;
    3. border-radius: 0px;
    4. border-width: 1px;
    5. padding: 0px;
    6. margin-bottom: -3px;
    7. margin-right: -3px;
    8. alternate-background-color: #EEF6FF;
    9. show-decoration-selected: 1;
    10. }
    To copy to clipboard, switch view to plain text mode 

    #EEF6FF is a light blue. But what I see when I run my application is a light gray for the alternating row color (the default). I DO see the correct color in the cell that contains the expansion arrow...but not in the branch area or the item cells.

    I've printed out the RGB values of the alternateBase of the QPalette used in the option objects...they're all correct, no surprises there... Indicating that my QSS file IS being used.

    I can't see any locations in my application's code where I'm changing the background color. (Any OBVIOUS locations anyway...and I didn't write all of the code. And there's a lot of it.)

    The basic flow from what I can tell is...we subclassed QTreeView, reimplemented drawRow (but we call the base class drawRow at the end of our code, which just does a transparent watermark across the rows). We have also subclassed QStyledItemDelegate and reimplemented paint (but even if I don't use that delegate for my view, there is no change in how the row colors are shown).

    Here's where I'm fuzzy: because the BRANCH area of the QTreeView row shows the default alt background color...as well as the rest of the row (with the exception of the one cell containing the expand arrow, which shows the light blue I want)...I can't believe that there is a place where I'm manually making this problem occur. Well. I could believe it, but at present I can't find it.

    Anyone seen behavior like this before? Any hints on where I should look? It did work perfectly in 4.6.3...

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Qt4.7.0 Alternate Row Color from QSS ignored (QTreeView)

    we subclassed QTreeView
    Don't know whether this will help but see Wysota's last post (#6) in this thread: link

  3. #3
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt4.7.0 Alternate Row Color from QSS ignored (QTreeView)

    Thanks for your reply!

    Hmm...an intriguing prospect. We did not reimplement paintEvent, and when I tried it just now, I ended up with completely blank tree views.

    I added the base QTreeView:: paintEvent call after the drawPrimitive call, and it was back to the default alt background row color (with the one blue cell containing the expand arrow) as if I had done nothing at all.

    I moved the base call before the drawPrimitive call, and it was the same outcome as having it after.

    I'm wondering what is significant about the fact that it worked in 4.6.3 but when upgraded to 4.7.0 this functionality suddenly stopped working...

Similar Threads

  1. Alternate row colours in QFormLayout
    By xtal256 in forum Qt Programming
    Replies: 9
    Last Post: 27th February 2011, 23:36
  2. QTreeView item color
    By tmmak in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2011, 07:08
  3. bg color of current item for a QTreeView
    By joeld42 in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 18:06
  4. About the background color of QTreeView itmes
    By yandy in forum Qt Programming
    Replies: 3
    Last Post: 26th March 2009, 16:38
  5. Changing the text color of a QTreeView leaf.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 23rd March 2006, 00:58

Tags for this Thread

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.