There is no way to apply stylesheets to custom shapes.
This is not so easy.I suppose it would be fairly straightfoward to read the styles from file and then make sure they're used in the paint function, I would have just preferred the skinning to be consistent with stylesheets like everything else.
I mean technically you can use stylesheets on custom widgets but only to an extent as you would use it on a plain QWidget (which is well... empty) or whatever the superclass of your widget is (where it is required that you draw the original shape of the widget). There is no way to control the way stylesheets are used with whatever you do in your paintEvent() except by drawing primitives offered by QStyle and handled by the stylesheet proxy behind it.What do you mean? You said stylesheets aren't supported on custom widgets but then you said I could apply it?
It calles QStyle API that performs the task. Since there is no API in QStyle for drawing triangular buttons you can't do the same for your custom widget. Of course you can parse stylesheets on your own (including all the inherited and conflicting definitions) but then you'll end up with effectively reimplementing the stylesheet mechanism.On another note, how does the standard QPushButton's paint function get the information contained in the stylesheet?
In your case it might be much easier to have a grayscale template for your shape and colour it on the fly with a given colour, that's pretty straightforward. Another possible and practiced approach is to use SVG for your graphics.
Bookmarks