July 22, 2011

alfah alfah
Lab Rat
157 posts

stylesheet for Messagebox

 

How do we apply style sheets for the default Message box. Somehow the background color as well as the text color of the QMessagebox has become white. As the result, i cannot read the text, can only see the blue ok and cancel buttons.

the docs said

“The messagebox-text-interaction-flags property can be used to alter the interaction with text in the message box.”
I found an example which said

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

how do i change the background and the text color. ?

This is my code.

  1. QMessageBox::StandardButton msgBox;
  2. msgBox=QMessageBox::information(this,tr("Start checking"),tr("Set date "),QMessageBox::Ok|QMessageBox::Cancel);

If any one can give suggestions or the previously answered links,

Thank you

alfah

1 reply

July 22, 2011

jensen82 jensen82
Ant Farmer
131 posts

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

Could you please post the contents of your stylesheet?

The example yourQtDir\examples\widgets\stylesheet may be helpful, too.

 
  ‹‹ sms received in qml and qt      Problem removing widgets from a layout ››

You must log in to post a reply. Not a member yet? Register here!