I think in this specific case, the options are either to fully define the 
indicator states in the stylesheet (if I understood the problem correctly), or 
to get down and dirty with the QItemDelegate for the QTreeView.
I played with that a bit, but have not found a good way to only change a color 
component. It is not actually a checkbox widget, but rather a paint style that 
draws it. You could draw your own checkbox however you want:

QItemDelegate.drawCheck()
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qitemdelegate.html#drawCheck

You would subclass and implement drawCheck to paint the checkbox however you 
want. I know it sucks to have to do that much work. If it were actually a 
tangible QCheckBox widget, then you could just access it and set the palette.



On Oct 17, 2012, at 7:01 PM, Jay Goodman wrote:

> I've also found frustration in QT not having a lot of specific methods for 
> setting colors.  However, you can always overload the paintEvent and repaint 
> the entire widget, but then you have to repaint the entire widget yourself, 
> including the check.  
> I've found this tutorial fairly helpful whenever I go down the road of 
> painting: http://zetcode.com/tutorials/pyqt4/drawing/
> 
>  def paintEvent(self, ev):
> 
>         p = QtGui.QPainter(self)
>         
>         if not p.isActive():
>             p.begin()
>         #do your painting here
>         ev.ignore()
> 
> On Wednesday, October 17, 2012 8:27:51 AM UTC+8, Geoff Harvey wrote:
> Y'all-
> 
> Is there any way to change the base color of a checkbox on a TreeWidgetItem 
> *without* having to redefine every little aspect of the QTreeWidget/QTreeView?
> 
> I can change the color with a stylesheet doing something like this ...
> 
> QTreeView::indicator {
>     color: rgb(240, 240, 240)
> }
> 
> ... but then I lose my checkbox icons.
> 
> This makes me sad.
> 
> Any ideas?
> 
> Thanks!
> 
> geoff
> 
> -- 
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings: 
> http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to