Corners disappear when I set the border radius

The following code:

app = QApplication([]) mainWindow = QMainWindow() mainWindow.show() textEdit = QTextEdit() mainWindow.setCentralWidget(textEdit) app.setStyleSheet(""" QTextEdit { margin: 10px; border: 1px solid black; border-radius: 20px; } """) app.exec_() 

Produces this result:

enter image description here

Oddly enough, if I set the background color, the corners are displayed as expected:

enter image description here

The corners are displayed in both cases, when I delete the radius of the border and even more strange, I can quickly fix it by setting background-color: white. Fields have nothing to do with the problem, I just found that the problem would be easier to see. What's going on here? This seems like a CSS / webkit issue in this question .

+4
source share
1 answer

I can confirm the problem with PyQt 5.6, and I assume this is an error.

It seems that QTextEdit has a white background rectangle by default, and it is drawn on top of the background specified in the stylesheet if there is no background color in the stylesheet, but not if the background color is specified in the stylesheet.

Why is this so, I do not know. We could check the sources of Qt and / or report an error there.

But you also found a workaround (specifying the background color as white or whatever you like), so I recommend doing this.

+1
source

All Articles