Important: Please read the Qt Code of Conduct -

setting border-radius does not clip the background?

  • Running Qt5.4.0 64bit on Windows 7.

    I set the following stylesheet on one of my panels:

        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

    Reality: background is not clipped, see
    [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?

  • I did some additional investigation and as far as I can tell, this really looks like a bug report. I filed for it

  • Moderators

    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);

    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.