设置空间背景色
setAutoFillBackground(true); //设置自动填充
1QPalette palette = this->palette();
1palette.setColor(QPalette::Background,Qt::black);
1setPalette(palette);
1注:QPalette::ColorRole
QPalette::Window | 10 | 通常指窗口部件的背景色 |
QPalette::Background | Window | This value is obsolete. Use Window instead. |
QPalette::WindowText | 0 | 通常指窗口不见的前景色; |
QPalette::Foreground | WindowText | This value is obsolete. Use WindowText instead. |
QPalette::Base | 9 | 指文本输入窗口部件(比如QtextEdit,QLinedit等)的背景色. |
QPalette::AlternateBase | 16 | Used as the alternate background color in views with alternating row colors (seeQAbstractItemView::setAlternatingRowColors()). |
QPalette::ToolTipBase | 18 | 提示符背景色 |
QPalette::ToolTipText | 19 | 提示符前景色 |
QPalette::Text | 6 | 与QPalette::Base一块使用,指文本输入窗口部件的前景色; |
QPalette::Button | 1 | 指按钮窗口部件的背景色; |
QPalette::ButtonText | 8 | 指按钮窗口部件的前景色. |
QPalette::BrightText | 7 | A text color that is very different from WindowText, and contrasts well with e.g. Dark. Typically used for text that needs to be drawn where Text or WindowText would give poor contrast, such as on pressed push buttons. Note that text colors can be used for things other than just words; text colors are usually used for text, but it's quite common to use the text color roles for lines, icons, etc. |
最后
以上就是贤惠冬日最近收集整理的关于QPalette设置各种背景色的全部内容,更多相关QPalette设置各种背景色内容请搜索靠谱客的其他文章。
发表评论 取消回复