QT CSS sets the color, font, etc. of the control.

CSS set fonts, colors, etc.

  • Two ways
  1. On the ui design page, find the attribute of the styleSheet of the control, open the input box, and enter the fixed format instruction settings:
  2. Use API interface settings, setStyleSheet interface.

The format of QString input in Method 1 and Method 2 is the same:

  • "
    Background : rgb(0,255,0);" Set the background to green.
  • "Color: rgb(255,0,0);"
    sets the color of text to red.
    Note that there is a ";" after each line

The way to use the code directly is:
setStyleSheet("background: rgb(0,255,0)");
setStyleSheet("color: red");

Guess you like

Origin blog.csdn.net/u013894391/article/details/102681457