I'm using Qt with Python, and I've got a mainwindow with a status bar at the bottom. I can display a message in the bar using a QLabel, and set the color of that message using something like "<font color=\"green\">In progress</font>"
for the QLabel text.
I would like to also put a temporary message in the status bar, and assign a color to that message as well. However since it's not a QLabel this time (I'm using QStatusBar::showMessage which just takes a QString) I can't change the color anymore. The tags above are not recognized and the entire string "<font color=\"green\">In progress</font>"
is shown in gray.
Does anyone have any ideas?
To set the background or text color for a QStatusBar, change it's styleSheet before showing the message:
self.status.setStyleSheet("QStatusBar{padding-left:8px;background:rgba(255,0,0,255);color:black;font-weight:bold;}")
self.status.showMessage("Error Cannot determine filepath", msecs= 5000)
on init, connect the QStatusBar's messageChanged(QString) to a statusChanged() function.
def statusChanged(self, args):
'''If there are no arguments (the message is being removed)
change the background back to transparent/ text back to black'''
if not args:
self.status.setStyleSheet("QStatusBar{padding-left:8px;background:rgba(0,0,0,0);color:black;font-weight:bold;}")
T