Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt messagebox stylesheet
Forum Updated to NodeBB v4.3 + New Features

Qt messagebox stylesheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    frodi
    wrote on 25 Feb 2019, 13:20 last edited by
    #1

    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?

    J 1 Reply Last reply 25 Feb 2019, 13:58
    0
    • F frodi
      25 Feb 2019, 13:20

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 25 Feb 2019, 13:58 last edited by jsulm
      #2

      @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).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      1/2

      25 Feb 2019, 13:20

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved