QT5 como definir a cor da fonte no QLabel

Como usar o Qt5 para definir a cor da fonte no QLabel.
Existem várias abordagens:
uma é usar o método setPalette (); a
outra é usar uma folha de estilos; a
terceira é usar QStyle; a
quarta é usar alguns estilos HTML simples.
 
O primeiro, usando o método setPalette (), é o seguinte:

QPalette pe;
pe.setColor (QPalette :: WindowText, Qt :: vermelho);
QLabel * label = novo QLabel (isto);
label-> setPalette (pe);
label-> setText ("Olá Mundo");

Segundo, a folha de estilo é a seguinte:
QLabel * label = new QLabel (this);
label-> setStyleSheet ("cor de fundo: rgb (250, 0, 0); tamanho da fonte: 60 px; cor: azul");
label-> setText ("Olá Mundo");

Terceiro, use QStyle

 

Quarto, use algum formato HTML simples:

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

Acho que você gosta

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