4
votes

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

Weirdly, if I set a background color, the corners show up as expected:

enter image description here

The corners show up fine in both cases when I remove the border-radius, and even more bizarrely, I can actually quick-fix this by setting background-color: white. The margin has no bearing on the issue, I just set that so the problem would be easier to see. What's going on here? It seems similar to the CSS/webkit problem in this question.

1

1 Answers

1
votes

I can confirm the issue on with PyQt 5.6 and I guess it's a bug.

Seems like QTextEdit has a white background rectangle by default and this is drawn over the background that is specified in the stylesheet if there is no background color given in the stylesheet, but it is not drawn if a background color is specified in the stylesheet.

Why this is so, I don't know. We could check the Qt sources and/or report a bug there.

But you also already found a workaround (specifying the background-color as white or whatever you like it to be), so I recommend to do that.