第一种,使用setPalette()方法如下:

1     QLabel *label = new QLabel(tr("Hello Qt!"));
2     QPalette pe;
3     pe.setColor(QPalette::WindowText,Qt::white);
4     label->setPalette(pe);

第二种,使用样式表如下:

1     setStyleSheet("color:red;"); 
2     //setStyleSheet("color:#ff6600;");

第三种,使用QStyle,在Qt Demo中有一个很好的讲解QStyle的例子,可以参考学习。

第四种,使用一些简单的HTML格式:

QLabel *label = new QLabel("<h2><i>Hello</i><font color=red>Qt!</font></h2>");

 

相关文章:

  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案