Quantcast
Channel: Active questions tagged qpainter - Stack Overflow
Viewing all articles
Browse latest Browse all 58

QSS properties for custom widget: How to implement hover and pressed states

$
0
0

I found this example on the web on how to implement custom properties accessible from QSS for custom QWidgets: https://wiki.qt.io/Qt_Style_Sheets_and_Custom_Painting_Example

Does anyone know how can I implement the widget so that I can have different colors for hover or pressed states?

Current stylesheet looks like this:

SWidget{ qproperty-lineColor: yellow; qproperty-rectColor: red;}

I want to be able to have something like this:

SWidget:hover{ qproperty-lineColor: blue; qproperty-rectColor: green;}SWidget:pressed{ qproperty-lineColor: orange; qproperty-rectColor: violet;}

Note: I know it is possible to implement mouse events and change the colors using qproperties specific to the mouse events, for example:

SWidget{ qproperty-lineColor: yellow; qproperty-rectColor: red; qproperty-lineColor-hover: orange; qproperty-rectColor-hover: violet;}

but I would like to be able to make it work using the original qss/css way.

Regards!


Viewing all articles
Browse latest Browse all 58

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>