Frage

Wie man einen bestimmten Stil zu einem gewissen QMessageBox in Qt setzen. Besonders würde Ich mag ein Meldungsfeld aufzurufen, die unten geschrieben wird durch eine Schriftgröße und Farbe für den Text „Gut gemacht !!!“ gesetzt wird.

QMessageBox::information(this, "Done", "Well done!!!");
War es hilfreich?

Lösung 3

I have formated the text of the QMessageBox with HTML code. Sorry for the question. And thanks for answers.

Andere Tipps

Using this static method you can not access QMessageBox directly, because its created and destroyed entirely inside function. But you may try to alter stylesheet property of calling object before call to this function. This means calling object should be descedant of QWidget...

something like this:

QString tmpStyleSheet=this->styleSheet();
this->setStyleSheet("style sheet for your QMessageBox");
QMessageBox::information(this, "Done", "Well done!!!");
this->setStyleSheet(tmpStyleSheet);

style of QMessageBox will inherit parent's style...

You will need to create a QMessageBox object for that particular message box and then either setStyle() or setStyleSheet(), in other words you cannot use the static helper method.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top