QPalette Class Reference

[QtGui module]

该QPalette类包含的颜色组每个插件的状态。More…

Types

  • enum ColorGroup { Active, Disabled, Inactive, NColorGroups, ..., Normal }
  • enum ColorRole { WindowText, Foreground, Button, Light, ..., NoRole }

Methods

  • __init__ (self)
  • __init__ (self, QColor button)
  • __init__ (self, Qt.GlobalColor button)
  • __init__ (self, QColor button, QColor background)
  • __init__ (self, QBrush foreground, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush background)
  • __init__ (self, QColor foreground, QColor background, QColor light, QColor dark, QColor mid, QColor text, QColor base)
  • __init__ (self, QPalette palette)
  • __init__ (self, QVariant variant)
  • QBrush alternateBase (self)
  • QBrush background (self)
  • QBrush base (self)
  • QBrush brightText (self)
  • QBrush brush (self, ColorGroup cg, ColorRole cr)
  • QBrush brush (self, ColorRole cr)
  • QBrush button (self)
  • QBrush buttonText (self)
  • int cacheKey (self)
  • QColor color (self, ColorGroup cg, ColorRole cr)
  • QColor color (self, ColorRole cr)
  • ColorGroup currentColorGroup (self)
  • QBrush dark (self)
  • QBrush foreground (self)
  • QBrush highlight (self)
  • QBrush highlightedText (self)
  • bool isBrushSet (self, ColorGroup cg, ColorRole cr)
  • bool isCopyOf (self, QPalette p)
  • bool isEqual (self, ColorGroup cr1, ColorGroup cr2)
  • QBrush light (self)
  • QBrush link (self)
  • QBrush linkVisited (self)
  • QBrush mid (self)
  • QBrush midlight (self)
  • QPalette resolve (self, QPalette)
  • int resolve (self)
  • resolve (self, int mask)
  • int serialNumber (self)
  • setBrush (self, ColorGroup cg, ColorRole cr, QBrush brush)
  • setBrush (self, ColorRole acr, QBrush abrush)
  • setColor (self, ColorGroup acg, ColorRole acr, QColor acolor)
  • setColor (self, ColorRole acr, QColor acolor)
  • setColorGroup (self, ColorGroup cr, QBrush foreground, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush background)
  • setCurrentColorGroup (self, ColorGroup cg)
  • QBrush shadow (self)
  • QBrush text (self)
  • QBrush toolTipBase (self)
  • QBrush toolTipText (self)
  • QBrush window (self)
  • QBrush windowText (self)

Special Methods

  • bool __eq__ (self, QPalette p)
  • bool __ne__ (self, QPalette p)

Detailed Description

该QPalette类包含的颜色组每个插件的状态。

调色板由三个颜色组:ActiveDisabledInactive。 Qt中的所有部件包含一个调色板,用自己的调色板画出自己。这使得用户界面易于配置和更容易保持一致。

如果您创建一个新的widget ,我们强烈建议您使用的颜色在调色板中,而非硬编码特定的颜色。

色组:

  • The Active group is used for the window that has keyboard focus.
  • The Inactive group is used for other windows.
  • The Disabled group is used for widgets (not windows) that are disabled for some reason.

活动和非活动窗口可以包含禁用的部件。 (残疾人士使用的部件通常被称为inaccessible or grayed out。 )

在大多数款式,活动和非活动看起来是一样的。

颜色和画笔可以在任何一个调色板中的颜色组与被设置为特定的角色setColor()和setBrush( ) 。颜色组中包含的一组颜色绘制自己使用的小工具。我们建议小部件使用颜色组的角色从调色板中,如“前台”和“基地” ,而不是字面的颜色,如“红色”或“绿松石” 。色彩的角色列举和定义的ColorRole文档。

我们强烈建议您使用当前样式的默认调色板(通过返回QApplication.palette())和修改是必要的。这是由Qt的部件进行绘制,当他们。

要修改调用函数的颜色组setColor()和setBrush( ) ,这取决于你是否想要一个纯粹的颜色或像素图的图案。

也有相应color()和brush( ) getter方法​​和常用的便利函数来获得ColorRole对于当前ColorGroupwindow( )windowText( )base()等

您可以使用拷贝构造函数和测试,看看如果两个调色板拷贝调色板identical using isCopyOf( ) 。

QPalette是通过使用优化implicit sharing,所以它是非常有效的传递QPalette对象作为参数。

Warning:有些样式不使用调色板的所有图纸,举例来说,如果他们利用原生主题引擎。这对于在Windows XP中, Windows Vista和Mac OS X的风格的情况下。


Type Documentation

  1. QPalette.ColorGroup
Constant Value Description
QPalette.Disabled 1
QPalette.Active 0
QPalette.Inactive 2
QPalette.Normal Active 同义词活跃
  1. QPalette.ColorRole

Color Roles

该ColorRole枚举定义了当前的图形用户界面中使用的不同象征意义的颜色角色。

中央角色是:

Constant Value Description
QPalette.Window 10 一般的背景色。
QPalette.Background Window 这个值是过时的。使用Window来代替。
QPalette.WindowText 0 一般的前景色。
QPalette.Foreground WindowText 这个值是过时的。使用代替WindowText的。
QPalette.Base 9 大多采用作为背景色的文本输入窗口小部件,但也可以用于其他绘画 - 如组合框的背景下拉列表和工具栏的句柄。它通常是白色或其它浅色。
QPalette.AlternateBase 16 作为与交替行的颜色欣赏到备用背景色(见QAbstractItemView.setAlternatingRowColors())。
QPalette.ToolTipBase 18 用作背景颜色QToolTipQWhatsThis。工具提示使用的颜色不活动组QPalette,因为工具提示未激活的窗口。
QPalette.ToolTipText 19 作为前景色QToolTipQWhatsThis。工具提示使用的颜色不活动组QPalette,因为工具提示未激活的窗口。
QPalette.Text 6 所使用的前景色Base。这通常是一样的WindowText,在这种情况下,它必须提供良好的对比度WindowBase
QPalette.Button 1 一般按钮的背景颜色。这样的背景可以从不同的Window因为有些款式需要不同的背景颜色的按钮。
QPalette.ButtonText 8 与使用的前景色Button颜色。
QPalette.BrightText 7 文本颜色是从非常不同WindowText,并与对比以及如Dark。通常用于需要绘制文本的地方Text or WindowText将得到较差的对比度,例如在压制的按钮。请注意,文本颜色,可用于东西不仅仅是文字等;文字颜色usually用于文本,但它是相当普遍使用的文字颜色角色的线条,图标等

有大多用于三维斜角和阴影效果一些色彩的角色。所有这些通常是衍生自Window以及在依赖于该关系的方式使用。例如,按钮依赖于它,使斜面看起来有吸引力,和Motif滚动条依赖于Mid是从稍微不同的Window

Constant Value Description
QPalette.Light 2 比打火机Button颜色。
QPalette.Midlight 3 之间ButtonLight
QPalette.Dark 4 比较深Button
QPalette.Mid 5 之间ButtonDark
QPalette.Shadow 11 一个非常暗的颜色。默认情况下,阴影颜色Qt.black

选定的(标记)的项目有两个作用:

Constant Value Description
QPalette.Highlight 12 颜色以指示所选项目或当前项目。默认情况下,突出显示颜色Qt.darkBlue
QPalette.HighlightedText 13 与对比的文字颜色Highlight。默认情况下,突出显示的文本颜色为Qt.white

有相关的超链接两种颜色的作用:

Constant Value Description
QPalette.Link 14 用于未访问过的超链接的文本颜色。默认情况下,链接颜色是Qt.blue
QPalette.LinkVisited 15 用于已访问的超链接的文本颜色。默认情况下, linkvisited颜色Qt.magenta

请注意,我们不使用LinkLinkVisited呈现在Qt的富文本时,那角色,我们建议您使用CSS和QTextDocument.setDefaultStyleSheet( )函数来改变链接的外观。例如:

  1. [QTextBrowser](qtextbrowser.html) browser;
  2. [QColor]($docs-qcolor.html) linkColor([Qt](qt.html).red);
  3. [QString](qstring.html) sheet = [QString](qstring.html).fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
  4. browser.document()->setDefaultStyleSheet(sheet);
Constant Value Description
QPalette.NoRole 17 没有作用;此特殊的作用通常被用来表示一个作用还没有被分配。

Method Documentation

  1. QPalette.__init__ (self)

构造一个使用应用程序的默认调色板调色板对象。

See also QApplication.setPalette()和QApplication.palette( ) 。

  1. QPalette.__init__ (self, QColor button)

构造一个调色板从button颜色。其他颜色的自动计算,在此基础上的色彩。Window将按钮的颜色为好。

  1. QPalette.__init__ (self, Qt.GlobalColor button)

构造一个调色板从button颜色。其他颜色的自动计算,在此基础上的色彩。Window将按钮的颜色为好。

  1. QPalette.__init__ (self, QColor button, QColor background)

构造一个调色板从button颜色和window。其他颜色的自动计算,根据这些颜色。

  1. QPalette.__init__ (self, QBrush foreground, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush background)

构造一个调色板。您可以通过其中的画笔,像素图或纯颜色windowTextbuttonlightdarkmidtextbright_textbasewindow

See also QBrush

  1. QPalette.__init__ (self, QColor foreground, QColor background, QColor light, QColor dark, QColor mid, QColor text, QColor base)
  1. QPalette.__init__ (self, QPalette palette)
  1. QPalette.__init__ (self, QVariant variant)

构造的副本p

这个构造函数是快的感谢implicit sharing

  1. QBrush QPalette.alternateBase (self)

[

返回当前颜色组的备用基地刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.background (self)

  1. QBrush QPalette.base (self)

[

返回当前颜色组的基本刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.brightText (self)

[

返回当前颜色组的光明前景文本刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.brush (self, ColorGroup cg, ColorRole cr)

[

返回刷中指定的颜色group中,用于给定的颜色role

]($docs-qbrush.html)

See also color( )setBrush()和ColorRole

  1. QBrush QPalette.brush (self, ColorRole cr)

[

这是一个重载函数。

]($docs-qbrush.html)

返回该已被设置为给定的彩色的画笔role在当前的ColorGroup

See also color( )setBrush()和ColorRole

  1. QBrush QPalette.button (self)

[

返回当前颜色组的按钮刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.buttonText (self)

[

返回当前颜色组的按钮文本前景刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. int QPalette.cacheKey (self)

返回一个数字,用于标识此内容QPalette对象。不同QPalette对象可以具有相同的密钥,如果它们指的是相同的内容。

该cacheKey ( )会改变,当调色板被改变。

  1. QColor QPalette.color (self, ColorGroup cg, ColorRole cr)

[

返回颜色中指定的颜色group中,用于给定的颜色role

]($docs-qcolor.html)

See also brush( )setColor()和ColorRole

  1. QColor QPalette.color (self, ColorRole cr)

[

这是一个重载函数。

]($docs-qcolor.html)

返回该已被设置为给定的颜色的颜色role在当前的ColorGroup

See also brush()和ColorRole

  1. ColorGroup QPalette.currentColorGroup (self)

[

返回调色板的当前颜色组。

]($docs-qpalette.html#ColorGroup-enum)

See also setCurrentColorGroup( ) 。

  1. QBrush QPalette.dark (self)

[

返回当前颜色组的暗刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.foreground (self)

  1. QBrush QPalette.highlight (self)

[

返回当前颜色组的重头戏刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.highlightedText (self)

[

返回当前颜色组的高亮文本刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. bool QPalette.isBrushSet (self, ColorGroup cg, ColorRole cr)

返回True如果ColorGroup cgColorRole cr已经在此之前的调色板设置,否则返回False 。

这个函数中引入了Qt 4.2中。

See also setBrush( ) 。

  1. bool QPalette.isCopyOf (self, QPalette p)

返回True如果这个调色板,p是彼此的副本,即其中一人被创建为其他既不其后修改的副本,否则返回False 。这比平等更严格的。

See also operator=()和operator==( ) 。

  1. bool QPalette.isEqual (self, ColorGroup cr1, ColorGroup cr2)

返回True (通常很快) ,如果色组cg1等于cg2否则返回False 。

  1. QBrush QPalette.light (self)

[

返回当前颜色组的光刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.link (self)

[

返回当前颜色组的未访问过的链接文字笔刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.linkVisited (self)

[

返回当前颜色组的访问链接文本刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.mid (self)

[

返回当前颜色组的中间刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.midlight (self)

[

返回当前颜色组的midlight刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QPalette QPalette.resolve (self, QPalette)

返回一个新的QPalette具有从属性复制other

  1. int QPalette.resolve (self)
  1. QPalette.resolve (self, int mask)
  1. int QPalette.serialNumber (self)
  1. QPalette.setBrush (self, ColorGroup cg, ColorRole cr, QBrush brush)

设置刷子对于给定的颜色role到指定的brush在调色板中的所有组。

See also brush( )setColor()和ColorRole

  1. QPalette.setBrush (self, ColorRole acr, QBrush abrush)

这是一个重载函数。

设置刷子中指定的颜色group中,用于给定的颜色role,以brush

See also brush( )setColor()和ColorRole

  1. QPalette.setColor (self, ColorGroup acg, ColorRole acr, QColor acolor)

设置颜色中指定的颜色group中,用于给定的颜色role到指定的固color

See also setBrush( )color()和ColorRole

  1. QPalette.setColor (self, ColorRole acr, QColor acolor)

这是一个重载函数。

设置用于给定的颜色的颜色role,所有的颜色组,到指定的固color

See also brush( )setColor()和ColorRole

  1. QPalette.setColorGroup (self, ColorGroup cr, QBrush foreground, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush background)

设置的组cg。您可以通过其中的画笔,像素图或纯颜色windowTextbuttonlightdarkmidtextbright_textbasewindow

See also QBrush

  1. QPalette.setCurrentColorGroup (self, ColorGroup cg)

调色板的当前颜色组设置为cg

See also currentColorGroup( ) 。

  1. QBrush QPalette.shadow (self)

[

返回当前颜色组的眼影刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.text (self)

[

返回当前颜色组的文本前景刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.toolTipBase (self)

返回当前颜色组的刀尖基地刷。这个刷子是由QToolTipQWhatsThis

Note:工具提示使用的颜色不活动组QPalette,因为工具提示未激活的窗口。

此功能被引入Qt的4.4 。

See also ColorRolebrush( ) 。

  1. QBrush QPalette.toolTipText (self)

返回当前颜色组的工具提示文本刷。这个刷子是由QToolTipQWhatsThis

Note:工具提示使用的颜色不活动组QPalette,因为工具提示未激活的窗口。

此功能被引入Qt的4.4 。

See also ColorRolebrush( ) 。

  1. QBrush QPalette.window (self)

[

返回当前颜色组的窗口(一般背景)刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. QBrush QPalette.windowText (self)

[

返回当前颜色组的窗口文本(一般前台)刷。

]($docs-qbrush.html)

See also ColorRolebrush( ) 。

  1. bool QPalette.__eq__ (self, QPalette p)
  1. bool QPalette.__ne__ (self, QPalette p)