QT5 cómo configurar el color de la fuente en QLabel

Cómo usar Qt5 para establecer el color de la fuente en QLabel.
Hay aproximadamente varios enfoques:
uno es usar el método setPalette (); el
otro es usar una hoja de estilo; el
tercero es usar QStyle; el
cuarto es usar algunos estilos HTML simples en él.
 
El primero, usando el método setPalette () es el siguiente:

QPalette pe;
pe.setColor (QPalette :: WindowText, Qt :: red);
QLabel * label = new QLabel (this);
etiqueta-> setPalette (pe);
label-> setText ("Hola mundo");

En segundo lugar, la hoja de estilo es la siguiente:
QLabel * label = new QLabel (this);
label-> setStyleSheet ("background-color: rgb (250, 0, 0); font-size: 60px; color: blue");
label-> setText ("Hola mundo");

Tercero, use QStyle

 

Cuarto, use un formato HTML simple:

QLabel * label = new QLabel (tr ("Hello Qt!"));
QLabel * label = new QLabel ("<h2> <i> Hola </i> <font color = red> Qt! </font> </h2>");
————————————————
原文 链接 : https: //blog.csdn.net/x_iya/java/article/details/17101081

Supongo que te gusta

Origin www.cnblogs.com/modentime/p/12760267.html
Recomendado
Clasificación