4

What I mean

QMessageBox::question, QMessageBox::warning, QMessageBox::critical, QMessageBox::Information { /* Base Text Size & Color */
font-size:12px;
color:#ffffff;
}

If I try QmessageBox .QLabel it's change font for all form/windows

end how add background if I use global setting for all

QDialog {
border-image: url(':/images/image') 0 0 0 0 stretch stretch;
}

it's set , but how set only for this QMessageBoxes.

This I understand , but hv another problem, I add to background

QMessageBox QLabel {
background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0.5 rgba(0, 0, 0, 102));
border:0;
border-radius:6px;
font-size:10px;
font-weight:bold;
padding-left:5px;
padding-right:5px;
padding-top:5px;
padding-bottom:5px; 

but it add to icon to , how fix this ?

enter image description here

tseries
  • 723
  • 1
  • 6
  • 14
  • Sorry, but what are you exactly trying to do? You want to add a background for all QMessageBoxes? or for the QDialog? – Ph03n1x Jul 18 '17 at 13:44
  • 1
    I try change the font color for QMessageBox ( Dialog's ) end add to them custom background. If i use Globally image for all QDialo's it's add to QMessageBoxes dialog to. With font for QLabel the same. – tseries Jul 18 '17 at 13:52
  • 1
    The problem is - if set globally black image - it's make unreadable black font on QmessageBox critical, Info etc ... For all form change the font is simple but how with qss - set style for only this qmessageboxes, – tseries Jul 18 '17 at 13:56

3 Answers3

4

Have you tried:

QMessageBox {
    background-color: rgb(51, 51, 51);
}

QMessageBox QLabel {
    color: rgb(200, 200, 200);
}

http://doc.qt.io/qt-5/stylesheet-syntax.html

Ph03n1x
  • 794
  • 6
  • 12
  • This I understand , but i hv another problem i add to background QMessageBox QLabel { background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0.5 rgba(0, 0, 0, 102)); border:0; border-radius:6px; font-size:10px; font-weight:bold; padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px; } but it add to icon to , how fix this ? – tseries Jul 18 '17 at 15:36
  • Where do you want to add the icon? Do you want to add an image to the message box? – Ph03n1x Jul 18 '17 at 16:43
  • For that you should use the "setIconPixmap(const QPixmap & pixmap)" function of the QMessageBox object. i.e.: messageBoxInstance.setIconPixmap(QPixMap(":/pictures/yourPic.jpg")); – Ph03n1x Jul 18 '17 at 16:54
  • How set icon i know – tseries Jul 18 '17 at 17:30
  • Isn't it your image that has a darker background? Maybe you can try photoshop to set the rest of the image to transparent. – Ph03n1x Jul 18 '17 at 17:46
2

You can also set the color with tags inside the string passed as parameter to the QMessageBox:

QMessageBox::question(this, "Question", "<FONT COLOR='#ff0000'>Are you ready?</FONT>",
                                  QMessageBox::Yes|QMessageBox::No);

Question messageBox with font color red


Eduardo
  • 21
  • 2
1
setStyleSheet("QMessageBox{background: rgb(255,0,0);  border: none;font-family: Arial; font-style: normal;  font-size: 15pt; color: #000000 ; }");

result enter image description here

Vahagn Avagyan
  • 750
  • 4
  • 16