• 10617阅读
  • 3回复

如何改变标签或者或者Widget的背景颜色啊 [复制链接]

上一主题 下一主题
离线justmeloo
 

只看楼主 倒序阅读 楼主  发表于: 2008-10-22
— 本帖被 XChinux 执行加亮操作(2008-10-22) —
想让一个标签背景色其他颜色。好像没有可设置的属性,如果不行把标签拖到一个 widget上面,,再改变widget的颜色行不行啊,好像也没有可设置的地方,晕怎么搞呢?
努力中的青春岁月
离线yfx2003

只看该作者 1楼 发表于: 2008-10-22
palette : QPalette
This property holds the widget's palette.
As long as no special palette has been set, this is either a special palette for the widget class, the parent's palette or (if this widget is a top level widget), the default application palette.
Note: The palette's background color will only have an effect on the appearance of the widget if the autoFillBackground property is set.
Warning: Do not use this function in conjunction with Qt Style Sheets. When using style sheets, the palette of a widget can be customized using the "color", "background-color", "selection-color", "selection-background-color" and "alternate-background-color".
Access functions:
const QPalette & palette () const
void setPalette ( const QPalette & )
See also QApplication::palette().
www.qtcn.org/gpq4/
ajaxref.okajax.com/
离线XChinux

只看该作者 2楼 发表于: 2008-10-22
使用palette或者使用styleSheet
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线lazybone
只看该作者 3楼 发表于: 2008-10-23
Jambi
------------------------
将label背景色设为红色
label.setStyleSheet("background-color: rgb(255, 0, 0);");
快速回复
限100 字节
 
上一个 下一个