Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. setting border-radius does not clip the background?
Forum Updated to NodeBB v4.3 + New Features

setting border-radius does not clip the background?

Scheduled Pinned Locked Moved Unsolved General and Desktop
stylesheetqt5.4.0windows 7 64 bibug
3 Posts 2 Posters 9.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jakob
    wrote on last edited by Jakob
    #1

    Running Qt5.4.0 64bit on Windows 7.

    I set the following stylesheet on one of my panels:

    *[styleAsPanel="true"]
    {
        background-color: white;
        border: 1px solid #4a4a4a;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-right-radius: 4px;
        border-bottom-left-radius: 4px;
    }
    

    Expectation: the panel background is clipped by setting the border radius (as documented also on http://doc.qt.io/qt-5/stylesheet-reference.html#border-radius-prop)

    Reality: background is not clipped, see http://ctrlv.in/675860
    [edit: I created a snapshot of a bottom-right corner - the problem however appears on each of the corners]

    Am I missing something, or did I hit a bug?

    J 1 Reply Last reply
    0
    • J Jakob

      Running Qt5.4.0 64bit on Windows 7.

      I set the following stylesheet on one of my panels:

      *[styleAsPanel="true"]
      {
          background-color: white;
          border: 1px solid #4a4a4a;
          border-top-left-radius: 0;
          border-top-right-radius: 0;
          border-bottom-right-radius: 4px;
          border-bottom-left-radius: 4px;
      }
      

      Expectation: the panel background is clipped by setting the border radius (as documented also on http://doc.qt.io/qt-5/stylesheet-reference.html#border-radius-prop)

      Reality: background is not clipped, see http://ctrlv.in/675860
      [edit: I created a snapshot of a bottom-right corner - the problem however appears on each of the corners]

      Am I missing something, or did I hit a bug?

      J Offline
      J Offline
      Jakob
      wrote on last edited by
      #2

      I did some additional investigation and as far as I can tell, this really looks like a bug report. I filed https://bugreports.qt.io/browse/QTBUG-49965 for it

      1 Reply Last reply
      0
      • Chris KawaC Online
        Chris KawaC Online
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        It's more of a limitation than a bug I think.

        To OS, by default a window is a rectangle, no matter how you paint it, and stylesheets are just a way to paint it.
        To cut out the corners you would need a mask. Something like:

        auto frame = new QWidget(parent, Qt::Popup);
        frame->setStyleSheet("background-color: red; border: 1px solid green; border-radius: 6px;");
        
        QPainterPath path;
        path.addRoundedRect(frame->rect(), 6, 6);
        frame->setMask(path.toFillPolygon().toPolygon());
        
        frame->show();
        

        The problem is that the mask is a bitmap (0-1), not an image with alpha, so you get a jagged edges, but for some radii it works pretty well.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved