Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QPalette

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.gui.QPalette

All Implemented Interfaces:
  QtJambiInterface, java.lang.Cloneable

    public class QPalette

extends QtJambiObject
implements java.lang.Cloneable

The `QPalette` class contains color groups for each widget state. A palette consists of three color groups: Active, Disabled, and Inactive. All widgets in Qt contain a palette and use their palette to draw themselves. 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:

- 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.

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`.

Nested Class Summary
`static class` | `QPalette.ColorGroup`
`static class` | `QPalette.ColorRole` See the description for details.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QPalette()` Constructs a palette object that uses the application's default palette.
`QPalette(QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush window)` Constructs a palette.
`QPalette(QColor button)` Constructs a palette from the `button` color.
`QPalette(QColor button, QColor window)` Constructs a palette from a `button` color and a `window`.
`QPalette(QPalette palette)` Constructs a copy of `p`.
`QPalette(Qt.GlobalColor button)` Constructs a palette from the `button` color.

Method Summary
`QBrush` | `alternateBase()` Returns the alternate base brush of the current color group.
`QBrush` | `base()` Returns the base brush of the current color group.
`QBrush` | `brightText()` Returns the bright text foreground brush of the current color group.
`QBrush` | `brush(QPalette.ColorGroup cg, QPalette.ColorRole cr)` Returns the brush in the specified color `group`, used for the given color `role`.
`QBrush` | `brush(QPalette.ColorRole cr)` Returns the brush that has been set for the given color `role` in the current `ColorGroup` .
`QBrush` | `button()` Returns the button brush of the current color group.
`QBrush` | `buttonText()` Returns the button text foreground brush of the current color group.
`long` | `cacheKey()` Returns a number that identifies the contents of this `QPalette` object.
`QPalette` | `clone()` This method is reimplemented for internal reasons
`QColor` | `color(QPalette.ColorGroup cg, QPalette.ColorRole cr)` Returns the color in the specified color `group`, used for the given color `role`.
`QColor` | `color(QPalette.ColorRole cr)` Returns the color that has been set for the given color `role` in the current `ColorGroup` .
`QPalette.ColorGroup` | `currentColorGroup()` Returns the palette's current color group.
`QBrush` | `dark()` Returns the dark brush of the current color group.
`QBrush` | `highlight()` Returns the highlight brush of the current color group.
`QBrush` | `highlightedText()` Returns the highlighted text brush of the current color group.
`boolean` | `isBrushSet(QPalette.ColorGroup cg, QPalette.ColorRole cr)` Returns true if the `ColorGroup` `cg` and `ColorRole` `cr` has been set previously on this palette; otherwise returns false.
`boolean` | `isCopyOf(QPalette p)` Returns true if this palette and `p` are copies of each other, i.e.
`boolean` | `isEqual(QPalette.ColorGroup cr1, QPalette.ColorGroup cr2)` Returns true (usually quickly) if color group `cg1` is equal to `cg2`; otherwise returns false.
`QBrush` | `light()` Returns the light brush of the current color group.
`QBrush` | `link()` Returns the unvisited link text brush of the current color group.
`QBrush` | `linkVisited()` Returns the visited link text brush of the current color group.
`QBrush` | `mid()` Returns the mid brush of the current color group.
`QBrush` | `midlight()` Returns the midlight brush of the current color group.
`void` | `readFrom(QDataStream ds)` Reads a QPalette
`QPalette` | `resolve(QPalette arg__1)` Returns a new `QPalette` that has attributes copied from `other`.
`void` | `setBrush(QPalette.ColorGroup cg, QPalette.ColorRole cr, QBrush brush)` Sets the brush in the specified color `group`, used for the given color `role`, to `brush`.
`void` | `setBrush(QPalette.ColorRole cr, QBrush brush)` Sets the brush for the given color `role` to the specified `brush` for all groups in the palette.
`void` | `setColor(QPalette.ColorGroup cg, QPalette.ColorRole cr, QColor color)` Sets the brush in the specified color `group`, used for the given color `role`, to the specified solid `color`.
`void` | `setColor(QPalette.ColorRole cr, QColor color)` Sets the color used for the given color `role`, in all color groups, to the specified solid `color`.
`void` | `setColorGroup(QPalette.ColorGroup cr, QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush window)` Sets a the group at `cg`.
`void` | `setCurrentColorGroup(QPalette.ColorGroup cg)` Set the palette's current color group to `cg`.
`QBrush` | `shadow()` Returns the shadow brush of the current color group.
`QBrush` | `text()` Returns the text foreground brush of the current color group.
`QBrush` | `toolTipBase()` Returns the tool tip base brush of the current color group.
`QBrush` | `toolTipText()` Returns the tool tip text brush of the current color group.
`QBrush` | `window()` Returns the window (general background) brush of the current color group.
`QBrush` | `windowText()` Returns the window text (general foreground) brush of the current color group.
`void` | `writeTo(QDataStream ds)` Writes thisQPalette

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QPalette

    public QPalette()

  Constructs a palette object that uses the application's default palette.

See also:
  `QApplication::setPalette()`, and `QApplication::palette()`.

### QPalette

    public 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

    public QPalette(QBrush windowText,
                    QBrush button,
                    QBrush light,
                    QBrush dark,
                    QBrush mid,
                    QBrush text,
                    QBrush bright_text,
                    QBrush base,
                    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`.

See also:
  `QBrush`.

### QPalette

    public QPalette(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

    public QPalette(QColor button,
                    QColor window)

  Constructs a palette from a `button` color and a `window`. The other colors are automatically calculated, based on these colors.

### QPalette

    public QPalette(QPalette palette)

  Constructs a copy of `p`.

  This constructor is fast thanks to implicit sharing.

Method Detail

### alternateBase

    public final QBrush alternateBase()

  Returns the alternate base brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### base

    public final QBrush base()

  Returns the base brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### brightText

    public final QBrush brightText()

  Returns the bright text foreground brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### brush

    public final QBrush brush(QPalette.ColorGroup cg,
                              QPalette.ColorRole cr)

  Returns the brush in the specified color `group`, used for the given color `role`.

See also:
  `color()`, `setBrush()`, and `ColorRole` .

### brush

    public final QBrush brush(QPalette.ColorRole cr)

  Returns the brush that has been set for the given color `role` in the current `ColorGroup` .

See also:
  `color()`, `setBrush()`, and `ColorRole` .

### button

    public final QBrush button()

  Returns the button brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### buttonText

    public final QBrush buttonText()

  Returns the button text foreground brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### cacheKey

    public final long cacheKey()

  Returns a number that identifies the contents of this `QPalette` object. Distinct `QPalette` objects can have the same key if they refer to the same contents.

  The `cacheKey()` will change when the palette is altered.

### color

    public final QColor color(QPalette.ColorGroup cg,
                              QPalette.ColorRole cr)

  Returns the color in the specified color `group`, used for the given color `role`.

See also:
  `brush()`, `setColor()`, and `ColorRole` .

### color

    public final QColor color(QPalette.ColorRole cr)

  Returns the color that has been set for the given color `role` in the current `ColorGroup` .

See also:
  `brush()`, and `ColorRole` .

### currentColorGroup

    public final QPalette.ColorGroup currentColorGroup()

  Returns the palette's current color group.

See also:
  `setCurrentColorGroup()`.

### dark

    public final QBrush dark()

  Returns the dark brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### highlight

    public final QBrush highlight()

  Returns the highlight brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### highlightedText

    public final QBrush highlightedText()

  Returns the highlighted text brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### isBrushSet

    public final boolean isBrushSet(QPalette.ColorGroup cg,
                                    QPalette.ColorRole cr)

  Returns true if the `ColorGroup` `cg` and `ColorRole` `cr` has been set previously on this palette; otherwise returns false.

See also:
  `setBrush()`.

### isCopyOf

    public final boolean isCopyOf(QPalette p)

  Returns 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==().

### isEqual

    public final boolean isEqual(QPalette.ColorGroup cr1,
                                 QPalette.ColorGroup cr2)

  Returns true (usually quickly) if color group `cg1` is equal to `cg2`; otherwise returns false.

### light

    public final QBrush light()

  Returns the light brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### link

    public final QBrush link()

  Returns the unvisited link text brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### linkVisited

    public final QBrush linkVisited()

  Returns the visited link text brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### mid

    public final QBrush mid()

  Returns the mid brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### midlight

    public final QBrush midlight()

  Returns the midlight brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### writeTo

    public final void writeTo(QDataStream ds)

  Writes thisQPalette

### readFrom

    public final void readFrom(QDataStream ds)

  Reads a QPalette

### resolve

    public final QPalette resolve(QPalette arg__1)

  Returns a new `QPalette` that has attributes copied from `other`.

### setBrush

    public final void setBrush(QPalette.ColorGroup cg,
                               QPalette.ColorRole cr,
                               QBrush brush)

  Sets the brush in the specified color `group`, used for the given color `role`, to `brush`.

See also:
  `brush()`, `setColor()`, and `ColorRole` .

### setBrush

    public final void setBrush(QPalette.ColorRole cr,
                               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` .

### setColor

    public final void setColor(QPalette.ColorGroup cg,
                               QPalette.ColorRole cr,
                               QColor color)

  Sets the brush in the specified color `group`, used for the given color `role`, to the specified solid `color`.

See also:
  `setBrush()`, `color()`, and `ColorRole` .

### setColor

    public final void setColor(QPalette.ColorRole cr,
                               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` .

### setColorGroup

    public final void setColorGroup(QPalette.ColorGroup cr,
                                    QBrush windowText,
                                    QBrush button,
                                    QBrush light,
                                    QBrush dark,
                                    QBrush mid,
                                    QBrush text,
                                    QBrush bright_text,
                                    QBrush base,
                                    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`.

See also:
  `QBrush`.

### setCurrentColorGroup

    public final void setCurrentColorGroup(QPalette.ColorGroup cg)

  Set the palette's current color group to `cg`.

See also:
  `currentColorGroup()`.

### shadow

    public final QBrush shadow()

  Returns the shadow brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### text

    public final QBrush text()

  Returns the text foreground brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### toolTipBase

    public final QBrush toolTipBase()

  Returns 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.

See also:
  `ColorRole` , and `brush()`.

### toolTipText

    public final QBrush toolTipText()

  Returns 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.

See also:
  `ColorRole` , and `brush()`.

### window

    public final QBrush window()

  Returns the window (general background) brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### windowText

    public final QBrush windowText()

  Returns the window text (general foreground) brush of the current color group.

See also:
  `ColorRole` , and `brush()`.

### clone

    public QPalette clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD