概述
设置空间背景色
setAutoFillBackground(true); //设置自动填充
QPalette palette = this->palette();
palette.setColor(QPalette::Background,Qt::black);
setPalette(palette);
注: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设置各种背景色所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复