PDA

View Full Version : Qt4.7.0 Alternate Row Color from QSS ignored (QTreeView)



DancingFirefly
15th February 2011, 02:03
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:


QTreeView, QTableView, QTableWidget, QTreeWidget {
background-color: #FFFFFF;
border-color: #C3C3C4;
border-radius: 0px;
border-width: 1px;
padding: 0px;
margin-bottom: -3px;
margin-right: -3px;
alternate-background-color: #EEF6FF;
show-decoration-selected: 1;
}


#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...

norobro
15th February 2011, 16:15
we subclassed QTreeViewDon't know whether this will help but see Wysota's last post (#6) in this thread: link (http://www.qtcentre.org/threads/37976-Q_OBJECT-and-CSS-background-image)

DancingFirefly
15th February 2011, 23:12
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...