Override painting behavior without subclassing widgets
-
I would like to change the way in which widgets are painted, similar to what you would achieve using stylesheets. However, I'm unable to subclass any of the widgets in a productive manner (I would have to override every
paintEvent()
for every widget I would want to change). The issue I have with stylesheets is the inability to set differentborder-image
s for each side; which appears to be completely possible in QML (see this), but not in normal Qt for C++. Is there a workaround?In case you're wondering, in pursuit of offering an alternative solution:
I am trying to style an existing program. Its design is established, and to change integral portions of the UI would not be viable for 1 pull request; it would create plenty of conflicts and apparent convolutions for new contributors. I have to keep things relatively simple as this is largely other peoples' code.EDIT: I've discovered that the
border-image
property technically does what I want to do. I think it's a little counter-intuitive that only the topmost-level shorthand is available, as I'd love to be able to useborder-image-slice
,border-image-width
,border-image-outset
, andborder-image-source
on their own. And I haven't figured out how to make this work like I want, but that doesn't pertain to the question asked initially (I will make a new topic and close this one). -
I would like to change the way in which widgets are painted, similar to what you would achieve using stylesheets. However, I'm unable to subclass any of the widgets in a productive manner (I would have to override every
paintEvent()
for every widget I would want to change). The issue I have with stylesheets is the inability to set differentborder-image
s for each side; which appears to be completely possible in QML (see this), but not in normal Qt for C++. Is there a workaround?In case you're wondering, in pursuit of offering an alternative solution:
I am trying to style an existing program. Its design is established, and to change integral portions of the UI would not be viable for 1 pull request; it would create plenty of conflicts and apparent convolutions for new contributors. I have to keep things relatively simple as this is largely other peoples' code.EDIT: I've discovered that the
border-image
property technically does what I want to do. I think it's a little counter-intuitive that only the topmost-level shorthand is available, as I'd love to be able to useborder-image-slice
,border-image-width
,border-image-outset
, andborder-image-source
on their own. And I haven't figured out how to make this work like I want, but that doesn't pertain to the question asked initially (I will make a new topic and close this one).@Ewan-Green implement a custom QGraphicsEffect