Qmessagebox background and text color

不羁的心 提交于 2020-12-15 05:53:06

问题


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:

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_()

回答1:


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

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


来源:https://stackoverflow.com/questions/50222954/qmessagebox-background-and-text-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!