PDA

View Full Version : Background Color is clippable?



noob_user
30th June 2020, 18:08
So I made a empty widget and started adjusting its Style Sheet properties while following a tutorial and I did not get the expected result.

the objective of this snippet should be to create a red hexagon with a white background.

code:

background: red;
width: 100px;
height: 100px;
clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 025%);

however the code snippet does not clip anything and the widget results in being all red.

is there a way to achieve the desired result?

Why I was following this tutorial:
I was trying to create some sort of polygon area to clip the background-color of my widget.

Thank you for any help in advance

ChristianEhrlicher
1st July 2020, 18:35
'clip-path' is no valid qss keyword: https://doc.qt.io/qt-5/stylesheet-reference.html

ChrisW67
3rd July 2020, 22:51
You can create your own widget sub-class and implement QWidget::paintEvent()
Take a look at the Shaped Clock Example (https://doc.qt.io/qt-5/qtwidgets-widgets-shapedclock-example.html)