Results 1 to 3 of 3

Thread: Background Color is clippable?

  1. #1
    Join Date
    Jun 2020
    Qt products

    Default Background Color is clippable?

    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.

    Qt Code:
    1. background: red;
    2. width: 100px;
    3. height: 100px;
    4. clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 025%);
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by noob_user; 30th June 2020 at 18:14.

  2. #2
    Join Date
    Jan 2006
    Bremen, Germany
    Thanked 73 Times in 69 Posts
    Qt products
    Qt3 Qt4
    Unix/X11 Windows

    Default Re: Background Color is clippable?

    'clip-path' is no valid qss keyword:

  3. #3
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default Re: Background Color is clippable?

    You can create your own widget sub-class and implement QWidget::paintEvent()
    Take a look at the Shaped Clock Example

Similar Threads

  1. QTreeWidgetItem and background color
    By swiety in forum Qt Programming
    Replies: 9
    Last Post: 26th October 2016, 07:25
  2. Background color animation
    By cszawisza in forum Qt Programming
    Replies: 4
    Last Post: 25th November 2015, 12:37
  3. Background color
    By FelixB in forum Qwt
    Replies: 4
    Last Post: 24th June 2013, 07:03
  4. Setting Background Color
    By SixDegrees in forum Qt Programming
    Replies: 5
    Last Post: 16th February 2011, 18:33
  5. Background color of GLWidget
    By mullwaden in forum Qt Programming
    Replies: 3
    Last Post: 21st August 2008, 17:24


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.