QPalette Class ReferenceThe QPalette class contains color groups for each widget state. Далее... #include <QPalette> Inherited by: QColorGroup. Открытые типы
Открытые функции
Связанные нечлены класса
Подробное описаниеThe QPalette class contains color groups for each widget state. A palette consists of three color groups: Active, Disabled, and Inactive. Все виджеты в Qt содержат палитру и используют свою палитру для отрисовки самих себя. This makes the user interface easily configurable and easier to keep consistent. If you create a new widget we strongly recommend that you use the colors in the palette rather than hard-coding specific colors. The color groups:
Both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out.) In most styles, Active and Inactive look the same. Colors and brushes can be set for particular roles in any of a palette's color groups with setColor() and setBrush(). A color group contains a group of colors used by widgets for drawing themselves. We recommend that widgets use color group roles from the palette such as "foreground" and "base" rather than literal colors like "red" or "turquoise". The color roles are enumerated and defined in the ColorRole documentation. We strongly recommend that you use the default palette of the current style (returned by QApplication::palette()) and modify that as necessary. This is done by Qt's widgets when they are drawn. To modify a color group you call the functions setColor() and setBrush(), depending on whether you want a pure color or a pixmap pattern. There are also corresponding color() and brush() getters, and a commonly used convenience function to get the ColorRole for the current ColorGroup: window(), windowText(), base(), etc. You can copy a palette using the copy constructor and test to see if two palettes are identical using isCopyOf(). QPalette is optimized by the use of implicit sharing, so it is very efficient to pass QPalette objects as arguments. Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows XP, Windows Vista, and the Mac OS X styles. See also QApplication::setPalette(), QWidget::setPalette(), and QColor. Описание типов-членовenum QPalette::ColorGroup
enum QPalette::ColorRoleThe ColorRole enum defines the different symbolic color roles used in current GUIs. The central roles are:
There are some color roles used mostly for 3D bevel and shadow effects. All of these are normally derived from Window, and used in ways that depend on that relationship. For example, buttons depend on it to make the bevels look attractive, and Motif scroll bars depend on Mid to be slightly different from Window.
Selected (marked) items have two roles:
There are two color roles related to hyperlinks:
Note that we do not use the Link and LinkVisited roles when rendering rich text in Qt, and that we recommend that you use CSS and the QTextDocument::setDefaultStyleSheet() function to alter the appearance of links. Например: QTextBrowser browser; QColor linkColor(Qt::red); QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name()); browser.document()->setDefaultStyleSheet(sheet);
Описание функций-членовQPalette::QPalette ()Constructs a palette object that uses the application's default palette. See also QApplication::setPalette() and QApplication::palette(). QPalette::QPalette ( const QColor & button )Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Window will be the button color as well. QPalette::QPalette ( Qt::GlobalColor button )Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Window will be the button color as well. QPalette::QPalette ( const QColor & button, const QColor & window )Constructs a palette from a button color and a window. The other colors are automatically calculated, based on these colors. QPalette::QPalette ( const QBrush & windowText, const QBrush & button, const QBrush & light, const QBrush & dark, const QBrush & mid, const QBrush & text, const QBrush & bright_text, const QBrush & base, const QBrush & window )Constructs a palette. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window. Смотрите также QBrush. QPalette::QPalette ( const QPalette & p )Constructs a copy of p. This constructor is fast thanks to implicit sharing. QPalette::~QPalette ()Destroys the palette. const QBrush & QPalette::alternateBase () constReturns the alternate base brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::base () constReturns the base brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::brightText () constReturns the bright text foreground brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::brush ( ColorGroup group, ColorRole role ) constReturns the brush in the specified color group, used for the given color role. See also color(), setBrush(), and ColorRole. const QBrush & QPalette::brush ( ColorRole role ) constЭто перегруженная функция. Returns the brush that has been set for the given color role in the current ColorGroup. See also color(), setBrush(), and ColorRole. const QBrush & QPalette::button () constReturns the button brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::buttonText () constReturns the button text foreground brush of the current color group. See also ColorRole and brush(). qint64 QPalette::cacheKey () constВозвращает число, которое идентифицирует содержимое данного объекта QPalette. Distinct QPalette objects can have the same key if they refer to the same contents. The cacheKey() will change when the palette is altered. const QColor & QPalette::color ( ColorGroup group, ColorRole role ) constReturns the color in the specified color group, used for the given color role. See also brush(), setColor(), and ColorRole. const QColor & QPalette::color ( ColorRole role ) constЭто перегруженная функция. Returns the color that has been set for the given color role in the current ColorGroup. See also brush() and ColorRole. ColorGroup QPalette::currentColorGroup () constReturns the palette's current color group. See also setCurrentColorGroup(). const QBrush & QPalette::dark () constReturns the dark brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::highlight () constReturns the highlight brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::highlightedText () constReturns the highlighted text brush of the current color group. See also ColorRole and brush(). bool QPalette::isBrushSet ( ColorGroup cg, ColorRole cr ) constReturns true if the ColorGroup cg and ColorRole cr has been set previously on this palette; otherwise returns false. Эта функция была введена в Qt 4.2. Смотрите также setBrush(). bool QPalette::isCopyOf ( const QPalette & p ) constReturns true if this palette and p are copies of each other, i.e. one of them was created as a copy of the other and neither was subsequently modified; otherwise returns false. This is much stricter than equality. See also operator=() and operator==(). bool QPalette::isEqual ( ColorGroup cg1, ColorGroup cg2 ) constReturns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false. const QBrush & QPalette::light () constReturns the light brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::link () constReturns the unvisited link text brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::linkVisited () constReturns the visited link text brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::mid () constReturns the mid brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::midlight () constReturns the midlight brush of the current color group. See also ColorRole and brush(). QPalette QPalette::resolve ( const QPalette & other ) constReturns a new QPalette that has attributes copied from other. void QPalette::setBrush ( ColorRole role, const QBrush & brush )Sets the brush for the given color role to the specified brush for all groups in the palette. See also brush(), setColor(), and ColorRole. void QPalette::setBrush ( ColorGroup group, ColorRole role, const QBrush & brush )Это перегруженная функция. Sets the brush in the specified color group, used for the given color role, to brush. See also brush(), setColor(), and ColorRole. void QPalette::setColor ( ColorGroup group, ColorRole role, const QColor & color )Sets the color in the specified color group, used for the given color role, to the specified solid color. See also setBrush(), color(), and ColorRole. void QPalette::setColor ( ColorRole role, const QColor & color )Это перегруженная функция. Sets the color used for the given color role, in all color groups, to the specified solid color. See also brush(), setColor(), and ColorRole. void QPalette::setColorGroup ( ColorGroup cg, const QBrush & windowText, const QBrush & button, const QBrush & light, const QBrush & dark, const QBrush & mid, const QBrush & text, const QBrush & bright_text, const QBrush & base, const QBrush & window )Sets a the group at cg. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window. Смотрите также QBrush. void QPalette::setCurrentColorGroup ( ColorGroup cg )Set the palette's current color group to cg. See also currentColorGroup(). const QBrush & QPalette::shadow () constReturns the shadow brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::text () constReturns the text foreground brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::toolTipBase () constReturns the tool tip base brush of the current color group. This brush is used by QToolTip and QWhatsThis. Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows. Эта функция была введена в Qt 4.4. See also ColorRole and brush(). const QBrush & QPalette::toolTipText () constReturns the tool tip text brush of the current color group. This brush is used by QToolTip and QWhatsThis. Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows. Эта функция была введена в Qt 4.4. See also ColorRole and brush(). const QBrush & QPalette::window () constReturns the window (general background) brush of the current color group. See also ColorRole and brush(). const QBrush & QPalette::windowText () constReturns the window text (general foreground) brush of the current color group. See also ColorRole and brush(). QPalette::operator QVariant () constReturns the palette as a QVariant bool QPalette::operator!= ( const QPalette & p ) constReturns true (slowly) if this palette is different from p; otherwise returns false (usually quickly). Note: The current ColorGroup is not taken into account when comparing palettes Смотрите также operator==(). QPalette & QPalette::operator= ( const QPalette & p )Assigns p to this palette and returns a reference to this palette. This operation is fast thanks to implicit sharing. bool QPalette::operator== ( const QPalette & p ) constReturns true (usually quickly) if this palette is equal to p; otherwise returns false (slowly). Note: The current ColorGroup is not taken into account when comparing palettes Смотрите также operator!=(). Связанные нечлены классаQDataStream & operator<< ( QDataStream & s, const QPalette & p )Writes the palette, p to the stream s and returns a reference to the stream. Смотрите также Формат операторов QDataStream. QDataStream & operator>> ( QDataStream & s, QPalette & p )Reads a palette from the stream, s into the palette p, and returns a reference to the stream. Смотрите также Формат операторов QDataStream. |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |