Qmessagebox 背景和文字颜色 [英] Qmessagebox background and text color

查看:382
本文介绍了Qmessagebox 背景和文字颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如你在上面看到的那样,我有消息回复.我已经设法将背景着色为黑色:

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);")

我唯一的目的是文本是白色的,背景是黑色的...

这是我的部分代码:

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

推荐答案

要更改 QMessageBox 文本的颜色,您必须使用以下行

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

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

这篇关于Qmessagebox 背景和文字颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆