HatHat556
HatHat556

Reputation: 91

PyQt Change Active Widget Highlight Colour

I have a PyQt window with a custom stylesheet. On MacOS the QLineEdit is highlighted in blue when it is active, which ruins the stylesheet I am using. Is there any way to either stop this from happening or change the highlight colour that is used?

Window

Upvotes: 1

Views: 696

Answers (1)

eyllanesc
eyllanesc

Reputation: 243897

You can change it using the QPalette:

le = QtWidgets.QLineEdit()
pal = le.palette()
pal.setColor(
    QtGui.QPalette.Active, QtGui.QPalette.Highlight, QtGui.QColor("black")
)
le.setPalette(pal)

Upvotes: 1

Related Questions