Home

QtColorComboBox Class Reference

The QtColorComboBox class provides a combobox with colors and texts. More...

#include <qtcolorcombobox.h>

List of all member functions.

Public Members

Signals


Detailed Description

The QtColorComboBox class provides a combobox with colors and texts.

Colors are inserted with insertColor(), which takes a color, a text, and an optional index position. The combobox can also be populated with a standard set of colors using setStandardColors(). Users can add their own colors if the color dialog is enabled (see setColorDialogEnabled()).

When a color is highlighted (for example when the mouse moves over it after the combobox has been dropped down), the highlighted() signal is emitted. When a color is activated (for example, clicked), the activated() signal is emitted. If the color dialog is enabled and the item clicked is the "More..." item at the end, the color dialog is popped up and if the user chooses a color the activated signal is emitted after the dialog closes.

Use color() to get the color at a certain index position, and currentColor() to get the color that is currently selected.

See also


Member Function Documentation

QtColorComboBox::QtColorComboBox ( QWidget * parent = 0, const char * name = 0 )

Constructs a QtColorComboBox with the color dialog disabled. The parent and name arguments are passed to the QComboBox's constructor.

void QtColorComboBox::activated ( const QColor & color ) [signal]

This signal is emitted when the color color has been activated.

QColor QtColorComboBox::color ( int index ) const

Returns the color at position index.

QColor QtColorComboBox::currentColor () const

Returns the current color.

void QtColorComboBox::highlighted ( const QColor & color ) [signal]

This signal is emitted when the color color has been highlighted on the popup color grid.

void QtColorComboBox::insertColor ( const QColor & color, const QString & name, int index = -1 )

Inserts the color color with the text name at position index.

If index is -1, then color is appended at the end of the list.

bool QtColorComboBox::isColorDialogEnabled () const

Returns true if the color dialog button is enabled; otherwise returns false.

void QtColorComboBox::setColorDialogEnabled ( bool enabled = true )

Enables the color dialog if enabled is true; otherwise disables it.

When the color dialog is enabled, an extra item is available at the bottom of the list of colors in the combobox with the translatable text "More...". Selecting this item will pop up the color dialog, allowing the user to add new colors to the list. The new colors will be called "User color 1", "User color 2", and so on; the names can be changed by translating "User color %1".

See also insertColor().

void QtColorComboBox::setCurrentColor ( const QColor & color )

Sets color to be the current color if color is one of the combobox's colors; otherwise does nothing.

See also insertColor().

void QtColorComboBox::setStandardColors ()

Adds the 17 predefined colors from the Qt namespace.

(The names given to the colors, "Black", "White", "Red", etc., are all translatable.)

See also insertColor().


This file is part of the Qt Solutions. Copyright © 2003-2006 Trolltech. All Rights Reserved.

Copyright © 2003-2006 TrolltechTrademarks
Qt Solutions