tags:

views:

781

answers:

2
+3  A: 

Do you need one of the abilities the css customization gives you, beyond what you can do directly? For changing the colors, you can do that directly with the palette of the widget, which should preserve your style.

Also, remember that style changes are inherited, so if any widget containing the tree on the right has a different style than any one containing the tree on the left, that may cause the changes as well.

Beyond that, I would think that this appears to be a Qt bug, if indeed the only difference is the css style sheet.

Caleb Huitt - cjhuitt
+2  A: 

The advice of going the QPalette route worked out. Here is the solution:

#if 0  // this causes the problem
    setStyleSheet(
        "background-color: #EAF5FF;"
        "alternate-background-color: #D5EAFF;"
    );
#else // this works correctly
    QPalette p = palette();
    p.setColor(QPalette::Base, QColor(qRgb(0xEA, 0xF5, 0xFF)));
    p.setColor(QPalette::AlternateBase, QColor(qRgb(0xD5, 0xEA, 0xFF)));
    setPalette(p);
#endif

Both methods should work according to the docs, so I'd say its a Qt bug.

Edit: After working with this new method over the past few days, I've noticed there may be a performance improvement also.

Mark Beckwith