Search code examples
qtborderqtstylesheets

Why do the borders of the four corners of a QMainWindow display white frames?


When I set a border to centralwidget in Qt, it has an unexpected white frame on the corners.

I'm using qss and a .ui file to construct it:

UI

#centralwidget{
 border-style:solid;
 border-color: #3e3e3e;
 border-width: 2px;
 border-radius: 20px;
}

And it shows like this:

Result

I can't understand why it has a white frame, and which object this frame belongs to.


Solution

  • That white border is not your centralwidget, it's the border of the window (Example: QMainWindow).

    Your central widget's border radius is bigger than your window's, so my suggestion is to change the stylsheet of your Window object.

    You can see here that the QMainWindow contains centralwidget:

    QMainWindow children hirearchy in Qt designer