PDA

View Full Version : QLineEDit back color



rossedward01.rh@gmail.com
14th July 2021, 16:49
I've implemented a change the Qapp QPalette which filters down to all my other widgets with the exception of QLineEdit. The background color (QPalette::Base) will not set unless I do it directly on that widget. QTextEdit works fine. I'm wondering if there is some problem with the QLineEdit not inheriting properly or maybe the parent is not set correctly. Any help welcome. Thanks.

stryga42
27th August 2021, 18:41
My feeling is that QPalette support is "not the most consistent". I think the preferred way to change the design nowadays is the styleSheet property. Try something like setStyleSheet("QWidget{background: #ffd8c0}"); on the topmost widget you want to change the color. See https://doc.qt.io/qt-5/stylesheet-reference.html for more explanation.

Ginsengelf
30th August 2021, 07:53
Hi, I played a bit with the preview in the Qt Designer, but I was not able to change the background of the QLineEdit with any of the roles. So I agree with stryga42, a stylesheet is probably the only way.

Ginsengelf