Unsolved Qt messagebox stylesheet
-
Hi everyone.
I am new to Qt. I am currently learning my way around Qt and need some help.
For context, I am checking a variable every 20sec with a function call. If the variable is set, a message box appears. This works, but it is the colour of the text and buttons I need to modify because my background is black.This is my function:
void MainWindow::connectionStatus() { Socket conn_checker; //if(connectionCheck()==false) if(tester) { // Pop-up window with connection warning QMessageBox msg(this); msg.critical(this,"Connection warning","<font color=\"White\">The remote is not connected to the amplifiers <br>Please check connection"); msg.setStyleSheet("background-color:red"); //msg.setStyleSheet("QMessageBox:{ background-color:red;}"); // Set connection status led to red ui->stat_Label->setText("Not connected!"); ui->stat_Label->setStyleSheet("color:red;"); } else { ui->stat_Label->setText("Connected"); ui->stat_Label->setStyleSheet("color:green;"); } }
I have managed to get the text white, but when it comes to the buttons of background I have tried some approaches but none have worked so far.
How can I make this happen?
-
@frodi critical() is a static method - setting stylesheet on a QMessageBox instance and then calling a static method does not make sense (also, you set stylesheet after calling critical).