com.trolltech.qt.gui
Class QColorDialog

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.core.QObject
                  extended by com.trolltech.qt.gui.QWidget
                      extended by com.trolltech.qt.gui.QDialog
                          extended by com.trolltech.qt.gui.QColorDialog
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QColorDialog
extends QDialog

The QColorDialog class provides a dialog widget for specifying colors. The color dialog's function is to allow users to choose colors. For example, you might use this in a drawing program to allow the user to set the brush color.

The static functions provide modal color dialogs.

The static getColor() function shows the dialog, and allows the user to specify a color. The getRgba() function does the same, but also allows the user to specify a color with an alpha channel (transparency) value.

The user can store customCount() different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. Use setCustomColor() to set the custom colors, and use customColor() to get them.

Additional widgets that allow users to pick colors are available as Qt Solutions.

The Standard Dialogs example shows how to use QColorDialog as well as other built-in Qt dialogs.


See also:
QColor, QFileDialog, QPrintDialog, QFontDialog, and Standard Dialogs Example.


Nested Class Summary
static class QColorDialog.ColorDialogOption
          This enum specifies various options that affect the look and feel of a color dialog.
static class QColorDialog.ColorDialogOptions
           
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QDialog
QDialog.DialogCode
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, 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
 QSignalEmitter.Signal1 colorSelected
          This signal takes 1 generic argument(s).
 QSignalEmitter.Signal1 currentColorChanged
          This signal takes 1 generic argument(s).
 
Fields inherited from class com.trolltech.qt.gui.QDialog
accepted, finished, rejected
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QColorDialog()
          Constructs a color dialog with the given parent.
QColorDialog(QColor initial)
          Constructs a color dialog with the given parent and specified initial color.
QColorDialog(QColor initial, QWidget parent)
          Constructs a color dialog with the given parent and specified initial color.
QColorDialog(QWidget parent)
          Constructs a color dialog with the given parent.
 
Method Summary
 QColor currentColor()
          This property holds the currently selected color in the dialog.
static int customColor(int index)
          Returns the custom color at the given index as a QRgb value.
static int customCount()
          Returns the number of custom colors supported by QColorDialog.
static QColor getColor()
          Pops up a modal color dialog, lets the user choose a color, and returns that color.
static QColor getColor(QColor initial)
          Pops up a modal color dialog, lets the user choose a color, and returns that color.
static QColor getColor(QColor initial, QWidget parent)
          Pops up a modal color dialog, lets the user choose a color, and returns that color.
static QColor getColor(QColor initial, QWidget parent, java.lang.String title)
          Pops up a modal color dialog with the given window title (or "Select Color" if none is specified), lets the user choose a color, and returns that color.
static QColor getColor(QColor initial, QWidget parent, java.lang.String title, QColorDialog.ColorDialogOption[] options)
          This is an overloaded method provided for convenience.
static QColor getColor(QColor initial, QWidget parent, java.lang.String title, QColorDialog.ColorDialogOptions options)
          Pops up a modal color dialog with the given window title (or "Select Color" if none is specified), lets the user choose a color, and returns that color.
static java.lang.Integer getRgba(int initial, QWidget parent)
           
static java.lang.Integer getRgba(QWidget parent)
           
 QColorDialog.ColorDialogOptions options()
          This property holds the various options that affect the look and feel of the dialog.
 QColor selectedColor()
          Returns the color that the user selected by clicking the OK or equivalent button.
 void setCurrentColor(QColor color)
          This property holds the currently selected color in the dialog.
static void setCustomColor(int index, int color)
          Sets the custom color at index to the QRgbcolor value.
 void setOption(QColorDialog.ColorDialogOption option)
          Sets the given option to be enabled if on is true; otherwise, clears the given option.
 void setOption(QColorDialog.ColorDialogOption option, boolean on)
          Sets the given option to be enabled if on is true; otherwise, clears the given option.
 void setOptions(QColorDialog.ColorDialogOption[] options)
          This is an overloaded method provided for convenience.
 void setOptions(QColorDialog.ColorDialogOptions options)
          This property holds the various options that affect the look and feel of the dialog.
static void setStandardColor(int index, int color)
          Sets the standard color at index to the QRgbcolor value.
 boolean testOption(QColorDialog.ColorDialogOption option)
          Returns true if the given option is enabled; otherwise, returns false.
 
Methods inherited from class com.trolltech.qt.gui.QDialog
accept, done, exec, isSizeGripEnabled, open, reject, result, setModal, setResult, setSizeGripEnabled
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, graphicsProxyWidget, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty
 
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
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

colorSelected

public final QSignalEmitter.Signal1 colorSelected

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QColor(named: color)>:

This signal is emitted just after the user has clicked OK to select a color to use. The chosen color is specified by color.

See also:
color, and currentColorChanged() .


currentColorChanged

public final QSignalEmitter.Signal1 currentColorChanged

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QColor(named: color)>:

This signal is emitted whenever the current color changes in the dialog. The current color is specified by color.

See also:
color, and colorSelected() .

Constructor Detail

QColorDialog

public QColorDialog()
Constructs a color dialog with the given parent.


QColorDialog

public QColorDialog(QWidget parent)
Constructs a color dialog with the given parent.


QColorDialog

public QColorDialog(QColor initial)
Constructs a color dialog with the given parent and specified initial color.


QColorDialog

public QColorDialog(QColor initial,
                    QWidget parent)
Constructs a color dialog with the given parent and specified initial color.

Method Detail

currentColor

public final QColor currentColor()
This property holds the currently selected color in the dialog.


options

public final QColorDialog.ColorDialogOptions options()
This property holds the various options that affect the look and feel of the dialog. By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

See also:
setOption(), and testOption().


selectedColor

public final QColor selectedColor()
Returns the color that the user selected by clicking the OK or equivalent button.

Note: This color is not always the same as the color held by the currentColor property since the user can choose different colors before finally selecting the one to use.


setCurrentColor

public final void setCurrentColor(QColor color)
This property holds the currently selected color in the dialog.


setOption

public final void setOption(QColorDialog.ColorDialogOption option)
Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also:
options, and testOption().


setOption

public final void setOption(QColorDialog.ColorDialogOption option,
                            boolean on)
Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also:
options, and testOption().


setOptions

public final void setOptions(QColorDialog.ColorDialogOption[] options)
This is an overloaded method provided for convenience.


setOptions

public final void setOptions(QColorDialog.ColorDialogOptions options)
This property holds the various options that affect the look and feel of the dialog. By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

See also:
setOption(), and testOption().


testOption

public final boolean testOption(QColorDialog.ColorDialogOption option)
Returns true if the given option is enabled; otherwise, returns false.

See also:
options, and setOption().


customColor

public static int customColor(int index)
Returns the custom color at the given index as a QRgb value.

See also:
setCustomColor().


customCount

public static int customCount()
Returns the number of custom colors supported by QColorDialog. All color dialogs share the same custom colors.


getColor

public static QColor getColor(QColor initial)
Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.


getColor

public static QColor getColor()
Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.


getColor

public static QColor getColor(QColor initial,
                              QWidget parent)
Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.


getColor

public static QColor getColor(QColor initial,
                              QWidget parent,
                              java.lang.String title,
                              QColorDialog.ColorDialogOption[] options)
This is an overloaded method provided for convenience.


getColor

public static QColor getColor(QColor initial,
                              QWidget parent,
                              java.lang.String title)
Pops up a modal color dialog with the given window title (or "Select Color" if none is specified), lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.

The options argument allows you to customize the dialog.


getColor

public static QColor getColor(QColor initial,
                              QWidget parent,
                              java.lang.String title,
                              QColorDialog.ColorDialogOptions options)
Pops up a modal color dialog with the given window title (or "Select Color" if none is specified), lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog.

The options argument allows you to customize the dialog.


setCustomColor

public static void setCustomColor(int index,
                                  int color)
Sets the custom color at index to the QRgbcolor value.

Note: This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog option.

See also:
customColor().


setStandardColor

public static void setStandardColor(int index,
                                    int color)
Sets the standard color at index to the QRgbcolor value.

Note: This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the QColorDialog::DontUseNativeDialog option.


getRgba

public static java.lang.Integer getRgba(int initial,
                                        QWidget parent)

getRgba

public static java.lang.Integer getRgba(QWidget parent)