Using PyQt, I'm trying to use a stylesheet to set the background color of a QLineEdit that I've added to a QGraphicsScene. Problem is the background color is the only property I can't seem to change. For example:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QGraphicsView, QGraphicsScene, QLineEdit
if __name__ == '__main__':
app = QApplication(sys.argv)
myWidget = QWidget()
myWidget.graphicsView = QGraphicsView(myWidget)
scene = QGraphicsScene()
lineEdit = QLineEdit()
lineEdit.setStyleSheet("QLineEdit { background-color : black; color : gray; }")
widgetItem = scene.addWidget(lineEdit)
myWidget.graphicsView.setScene(scene)
myWidget.show()
sys.exit(app.exec_())
will set the text color of the line edit to gray, but the background color remains white.
What am I doing wrong?