'Qmessagebox background and text color

enter image description here

I have message response as you see on the above. I've managed to colour background to black:

msg.setStyleSheet("background-color: rgb(0, 0, 0);")

I've tried with same way for the text but it looks like this:

enter image description here

msg.setStyleSheet("text-color: rgb(255, 255, 255);")

My only purpose is texts are white and background is black...

Here is my part of code:

msg = QMessageBox()
msg.setText("Message has been sended")
msg.setWindowTitle("SENT")
msg.setWindowIcon(QtGui.QIcon("black tic.png"))
msg.setIcon(QMessageBox.Information)
msg.setStyleSheet("background-color: rgb(0, 0, 0);")
msg.setStyleSheet("text-color: rgb(255, 255, 255);")
msg.exec_()


Solution 1:[1]

To change the color of the text of a QMessageBox, you have to use the following line

msgBox.setStyleSheet("QLabel{ color: white}");

Solution 2:[2]

Try this one, it works fine...

msg.setStyleSheet("color:white;background:black")

Solution 3:[3]

msg = QMessageBox()
msg.setText("Message has been sended")
msg.setWindowTitle("SENT")
msg.setWindowIcon(QtGui.QIcon("black tic.png"))
msg.setIcon(QMessageBox.Information)
msg.setStyleSheet("background-color: rgb(0, 0, 0);color: rgb(255, 255, 255);")
msg.exec_()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 barbsan
Solution 2 Jawad Hussain Shah
Solution 3 RiveN