I am trying to create a demonstration app to show how to change font colors.
I can do it in QLabel and QTextEdit
I have found no way to change the foreground text color for a QLineEdit.
The only thing I've tried that does not throw an error is:
color = QColorDialog.getColor(defaultHost.textColor(), pWidget, 'Get Text Color')
myPalette.setColor(myPalette.WindowText, QColor(color))
But, the text color remains black...
Is it or is it not possible to do this?
You can do it by setting the object's style sheet:
self.my_line_edit = QtGui.QLineEdit()
self.my_line_edit.setStyleSheet("color: red;")
# or
self.my_line_edit.setStyleSheet("color: rgb(255, 0, 0);")
# or
self.my_line_edit.setStyleSheet("""
QLabel {
color: red;
}
""")