title: Changing the background colour of label in QT
body: <p>I have a main window and a label on it. This has to be displayed on full screen. A data will displayed on label. The background should be black and text needs to be white. I am receiving data like <code>1 or 2 or 3</code> via serial and I am fetching the related text of <code>1 or 2 or 3</code> from a file. I am also adjusting the text to fill the complete label. If the text is small, then its font size need to be increase and if it is large then it need to be small font size. </p>
  
  <p>I am using stylesheet to make the background color of label to black and I am putting it after adjusting the font size of the text. Like below:</p>
  
  <pre><code>void MainWindow::SerialRead()
  {
     //Reading the serial data
     //Reading the string from file
     //Adjusting the font size to fill the label
  
     //Changing color
     ui-&gt;label-&gt;setStyleSheet("QLabel{ background-color : black; color : white; }");
  }
  </code></pre>
  
  <p>So after this my outcome looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Ck2ns.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ck2ns.png" alt="enter image description here"></a></p>
  
  <p>As you can see in the above image, there is white border which is of main window because we have not set the back color of main window (it is not clearly visible because webpage color is also white). I also want the color of main window to be black so that full screen is black and text is white. I also tried setting the stylesheet in main.c for main window like below:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
    QApplication a(argc, argv);
    MainWindow app;
    //Chaning color
    app.setStyleSheet("QMainWindow {background-color : black;}");
    app.SerialInit();
    app.SerialWrite();
    app.showFullScreen();
  
    return a.exec();
  }
  </code></pre>
  
  <p>So it does changes the color of main window to black but the outcome looks like below:</p>
  
  <p><a href="https://i.stack.imgur.com/tXFsu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tXFsu.png" alt="enter image description here"></a></p>
  
  <p>As you can see it also changes the font size of the text which I do not want. How can I achieve this.?</p>