QMessageBox
-
Hi, I have a problem with QMessageBox.
I have created different messages both information and warning messages. They appear correctly in the interface but the problem is that when they appear, I automatically change the color of the buttons and labels of my interface. Once I close the message my interface goes back to the colors that I have assigned to it. Could you help me?
The first image is the normal colors of my interface, the second one is when it changes when the message appears. I need these colors not to change.
THANKS!!!!
-
Hi and welcome to devnet,
Do you have any style sheet applied in your application ?
-
@AEM22 said in QMessageBox:
I automatically change the color of the buttons and labels of my interface
Can you share your code here how you do the above and how you create and show the dialogs?
@mchinand yes!
For example:
I show the buttons as follows:
this->ui->botonIncrementar->setStyleSheet("background-color : #a8d2a0");
this->ui->botonDecrementar->setStyleSheet("background-color : #a8d2a0");
this->ui->botonIncrementar->show();
this->ui->botonDecrementar->show();In this way they are displayed with the colors I need.
Then I start working with QMessageBox and when the message appears is when I change these initial colors and once I close the message, they return to their initial colors.
mensajeInfo.information(this,"Información","¡Gracias!"); -
When are you changing these colors ?
Are you still showing the same widget as before the message box is shown ? -
When are you changing these colors ?
Are you still showing the same widget as before the message box is shown ?@SGaist said in QMessageBox:
When are you changing these colors ?
Are you still showing the same widget as before the message box is shown ?Initially my interface appears with the colors I want and that's when I use the SetStyleSheet, then while the message is displayed, that's when it changes the color to black. Once I hit Ok on that message, the colors return to the colors I want and set using the SetStyleSheet.
I explain, the problem is that while the message is on screen, the colors are not the right ones, once I remove that message, everything returns to its colors. -
Can you provide a minimal compilable example that shows this behaviour ?