• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KColorDialog Class Reference

A color selection dialog. More...

#include <kcolordialog.h>

Inheritance diagram for KColorDialog:
Inheritance graph
[legend]

List of all members.

Public Slots

void setColor (const QColor &col)

Signals

void colorSelected (const QColor &col)

Public Member Functions

 KColorDialog (QWidget *parent=0L, bool modal=false)
 ~KColorDialog ()
QColor color () const
QColor defaultColor () const
void setDefaultColor (const QColor &defaultCol)

Static Public Member Functions

static int getColor (QColor &theColor, const QColor &defaultColor, QWidget *parent=0L)
static int getColor (QColor &theColor, QWidget *parent=0L)
static QColor grabColor (const QPoint &p)

Protected Member Functions

virtual bool eventFilter (QObject *obj, QEvent *ev)
virtual void keyPressEvent (QKeyEvent *)
virtual void mouseMoveEvent (QMouseEvent *)
virtual void mouseReleaseEvent (QMouseEvent *)

Detailed Description

A color selection dialog.

Features:

  • Color selection from a wide range of palettes.
  • Color selection from a palette of H vs S and V selectors.
  • Direct input of HSV or RGB values.
  • Saving of custom colors

In most cases, you will want to use the static method KColorDialog::getColor(). This pops up the dialog (with an initial selection provided by you), lets the user choose a color, and returns.

Example:

    QColor myColor;
    int result = KColorDialog::getColor( myColor );
         if ( result == KColorDialog::Accepted )
            ...

To react to the color selection as it is being selected, the colorSelected() signal can be used. This can be used still in a modal way, for example:

  KColorDialog dialog(this);
  connect(&dialog, SIGNAL(colorSelected(const QColor &)), this, SLOT(temporarilyChangeColor(const QColor &)));
  QColor myColor;
  dialog.setColor(myColor);
  int result = dialog.exec();

  if ( result == KColorDialog::Accepted )
    changeColor( dialog.color() );
  else
    temporarilyChangeColor(myColor); //change back to original color
kcolordialog.png

KDE Color Dialog

The color dialog is really a collection of several widgets which can you can also use separately: the quadratic plane in the top left of the dialog is a KXYSelector. Right next to it is a KHSSelector for choosing hue/saturation.

On the right side of the dialog you see a KColorTable showing a number of colors with a combo box which offers several predefined palettes or a palette configured by the user. The small field showing the currently selected color is a KColorPatch.

Definition at line 204 of file kcolordialog.h.


Constructor & Destructor Documentation

KColorDialog::KColorDialog ( QWidget *  parent = 0L,
bool  modal = false 
) [explicit]

Constructs a color selection dialog.

Definition at line 981 of file kcolordialog.cpp.

KColorDialog::~KColorDialog (  ) 

Destroys the color selection dialog.

Definition at line 1237 of file kcolordialog.cpp.


Member Function Documentation

QColor KColorDialog::color (  )  const

Returns the currently selected color.

Definition at line 1442 of file kcolordialog.cpp.

void KColorDialog::colorSelected ( const QColor &  col  )  [signal]

Emitted when a color is selected.

Connect to this to monitor the color as it as selected if you are not running modal.

QColor KColorDialog::defaultColor (  )  const
Returns:
the value passed to setDefaultColor

Definition at line 1293 of file kcolordialog.cpp.

bool KColorDialog::eventFilter ( QObject *  obj,
QEvent *  ev 
) [protected, virtual]

Definition at line 1247 of file kcolordialog.cpp.

int KColorDialog::getColor ( QColor &  theColor,
const QColor &  defaultColor,
QWidget *  parent = 0L 
) [static]

Creates a modal color dialog, lets the user choose a color, and returns when the dialog is closed.

The selected color is returned in the argument theColor.

This version takes a defaultColor argument, which sets the color selected by the "default color" checkbox. When this checkbox is checked, the invalid color (QColor()) is returned into theColor.

Parameters:
theColor if valid, specifies the color to be initially selected. On return, holds the selected color.
defaultColor color selected by the "default color" checkbox
Returns:
QDialog::result().

Definition at line 1477 of file kcolordialog.cpp.

int KColorDialog::getColor ( QColor &  theColor,
QWidget *  parent = 0L 
) [static]

Creates a modal color dialog, let the user choose a color, and returns when the dialog is closed.

The selected color is returned in the argument theColor.

Parameters:
theColor if valid, specifies the color to be initially selected. On return, holds the selected color.
Returns:
QDialog::result().

Definition at line 1459 of file kcolordialog.cpp.

QColor KColorDialog::grabColor ( const QPoint &  p  )  [static]

Gets the color from the pixel at point p on the screen.

Definition at line 1779 of file kcolordialog.cpp.

void KColorDialog::keyPressEvent ( QKeyEvent *  event  )  [protected, virtual]

For internal use only.

Reimplemented from KDialog.

Definition at line 1807 of file kcolordialog.cpp.

void KColorDialog::mouseMoveEvent ( QMouseEvent *  e  )  [protected, virtual]

Definition at line 1751 of file kcolordialog.cpp.

void KColorDialog::mouseReleaseEvent ( QMouseEvent *  e  )  [protected, virtual]

Definition at line 1762 of file kcolordialog.cpp.

void KColorDialog::setColor ( const QColor &  col  )  [slot]

Preselects a color.

Definition at line 1451 of file kcolordialog.cpp.

void KColorDialog::setDefaultColor ( const QColor &  defaultCol  ) 

Call this to make the dialog show a "Default Color" checkbox.

If this checkbox is selected, the dialog will return an "invalid" color (QColor()). This can be used to mean "the default text color", for instance, the one with the KDE text color on screen, but black when printing.

Definition at line 1265 of file kcolordialog.cpp.


The documentation for this class was generated from the following files:
  • kcolordialog.h
  • kcolordialog.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  •     Sodep
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal