K
K
Kurum2017-02-01 14:59:45
PyQt
Kurum, 2017-02-01 14:59:45

PyQt4 | How to change color for QTextEdit?

I wrote a code that doesn't work:

self.edit.color = QtGui.QColor("#7b3f00")
self.edit.setTextColor(self.edit.color)

What is the correct way to change color for QTextEdit?
The answer is preferably written in code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qlkvg, 2017-02-01
@Pyrym

# для изменения цвета текста
self.edit.setStyleSheet("QTextEdit {color:red}")
# для изменения цвета бэкграунда
self.edit.setStyleSheet("QTextEdit {background-color:red}")

or
# для изменения цвета текста
self.edit.setStyleSheet("QTextEdit {color:rgba(255, 0, 0, 255)}")
# для изменения цвета бэкграунда
self.edit.setStyleSheet("QTextEdit {background-color:rgba(255, 0, 0, 255)}")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question