Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QtGradientDialog Class Reference

Inheritance diagram for QtGradientDialog:

QDialog QWidget QObject

List of all members.


Detailed Description

The QtGradientDialog class provides a dialog for specifying gradients.

The gradient dialog's function is to allow users to edit gradients. For example, you might use this in a drawing program to allow the user to set the brush gradient.

qtgradientdialog.png qtgradientdialogextension.png Details extension hidden Details extension visible

Starting from the top of the dialog there are several buttons:

The first three buttons allow for changing a type of the gradient (QGradient::Type), while the second three allow for changing spread of the gradient (QGradient::Spread). The last button shows or hides the details extension of the dialog. Conceptually the default view with hidden details provides the full functional control over gradient editing. The additional extension with details allows to set gradient's parameters more precisely. The visibility of extension can be controlled by detailsVisible property. Moreover, if you don't want the user to switch on or off the visibility of extension you can set the detailsButtonVisible property to false.

Below top buttons there is an area where edited gradient is interactively previewed. In addition the user can edit gradient type's specific parameters directly in this area by dragging appropriate handles.

qtgradientdialoglineareditor.png qtgradientdialogradialeditor.png qtgradientdialogconicaleditor.png Editing linear type Editing radial type Editing conical type The user can change the start and final point positions by dragging the circular handles. The user can change the center and focal point positions by dragging the circular handles and can change the gradient's radius by dragging horizontal or vertical line. The user can change the center point by dragging the circular handle and can change the gradient's angle by dragging the big wheel.

In the middle of the dialog there is an area where the user can edit gradient stops.

qtgradientdialogstops.png qtgradientdialogstopszoomed.png

The top part of this area contains stop handles, and bottom part shows the preview of gradient stops path. In order to create a new gradient stop double click inside the view over the desired position. If you double click on existing stop handle in the top part of the view, clicked handle will be duplicated (duplicate will contain the same color). The stop can be activated by clicking on its handle. You can activate previous or next stop by pressing left or right key respectively. To jump to the first or last stop press home or end key respectively. The gradient stops editor supports multiselection. Clicking a handle holding the shift modifier key down will select a range of stops between the active stop and clicked one. Clicking a handle holding control modifier key down will remove from or add to selection the clicked stop depending if it was or wasn't already selected respectively. Multiselection can also be created using rubberband (by pressing the left mouse button outside of any handle and dragging). Sometimes it's hard to select a stop because its handle can be partially covered by other handle. In that case the user can zoom in the view by spinning mouse wheel. The selected stop handles can be moved by drag & drop. In order to remove selected stops press delete key. For convenience context menu is provided with the following actions:

New Stop - creates a new gradient stop Delete - removes the active and all selected stops Flip All - mirrors all stops Select All - selects all stops Zoom In - zooms in Zoom Out - zooms out Zoom All - goes back to original 100% zoom

The bottom part of the QtGradientDialog contains a set of widgets allowing to control the color of the active and selected stops.

qtgradientdialogcolorhsv.png qtgradientdialogcolorrgb.png

The color button shows the color of the active gradient stop. It also allows for choosing a color from standard color dialog and applying it to the active stop and all selected stops. It's also possible to drag a color directly from the color button and to drop it in gradient stops editor at desired position (it will create new stop with dragged color) or at desired stop handle (it will change the color of that handle).

To the right of color button there is a set of 2 radio buttons which allows to switch between HVS and RGB color spec.

Finally there are 4 color sliders working either in HSVA (hue saturation value alpha) or RGBA (red green blue alpha) mode, depending on which radio button is chosen. The radio buttons can be controlled programatically by spec() and setSpec() methods. The sliders show the color of the active stop. By double clicking inside color slider you can set directly the desired color. Changes of slider's are applied to stop selection in the way that the color component being changed is applied to stops in selection only, while other components remain unchanged in selected stops (e.g. when the user is changing the saturation, new saturation is applied to selected stops preventing original hue, value and alpha in multiselection).

The convenient static functions getGradient() provide modal gradient dialogs, e.g.:

doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp 0

In order to have more control over the properties of QtGradientDialog use standard QDialog::exec() method:

doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp 1

See also:
{Gradient View Example}

Definition at line 49 of file qtgradientdialog.h.


Public Types

enum  DialogCode { Rejected, Accepted }
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }

Public Slots

virtual void accept ()
bool close ()
void deleteLater ()
virtual void done (int)
int exec ()
void hide ()
void lower ()
void open ()
void raise ()
virtual void reject ()
void repaint ()
void setDisabled (bool)
void setEnabled (bool)
void setFocus ()
void setHidden (bool hidden)
QT_MOC_COMPAT void setShown (bool shown)
void setStyleSheet (const QString &styleSheet)
void setWindowModified (bool)
void setWindowTitle (const QString &)
void show ()
void showExtension (bool)
void showFullScreen ()
void showMaximized ()
void showMinimized ()
void showNormal ()
void update ()

Signals

void accepted ()
void customContextMenuRequested (const QPoint &pos)
void destroyed (QObject *=0)
void finished (int result)
void rejected ()

Public Member Functions

bool acceptDrops () const
QString accessibleDescription () const
QString accessibleName () const
QList< QAction * > actions () const
void activateWindow ()
void addAction (QAction *action)
void addActions (QList< QAction * > actions)
void adjustSize ()
bool autoFillBackground () const
QPalette::ColorRole backgroundRole () const
QSize baseSize () const
bool blockSignals (bool b)
QWidgetchildAt (const QPoint &p) const
QWidgetchildAt (int x, int y) const
const QObjectListchildren () const
QRect childrenRect () const
QRegion childrenRegion () const
void clearFocus ()
void clearMask ()
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
QRect contentsRect () const
Qt::ContextMenuPolicy contextMenuPolicy () const
void createWinId ()
QCursor cursor () const
int depth () const
bool detailsVisible () const
int devType () const
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
void dumpObjectInfo ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
WId effectiveWinId () const
void ensurePolished () const
QWidgetextension () const
template<typename T>
findChild (const QString &aName=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &aName=QString()) const
Qt::FocusPolicy focusPolicy () const
QWidgetfocusProxy () const
QWidgetfocusWidget () const
const QFontfont () const
QFontInfo fontInfo () const
QFontMetrics fontMetrics () const
QPalette::ColorRole foregroundRole () const
QRect frameGeometry () const
QSize frameSize () const
const QRectgeometry () const
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
void grabKeyboard ()
void grabMouse (const QCursor &)
void grabMouse ()
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
QGradient gradient () const
QGraphicsProxyWidgetgraphicsProxyWidget () const
Qt::HANDLE handle () const
bool hasFocus () const
bool hasMouseTracking () const
int height () const
virtual int heightForWidth (int) const
int heightMM () const
bool inherits (const char *classname) const
QInputContextinputContext ()
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
void insertAction (QAction *before, QAction *action)
void insertActions (QAction *before, QList< QAction * > actions)
void installEventFilter (QObject *)
WId internalWinId () const
bool isActiveWindow () const
bool isAncestorOf (const QWidget *child) const
bool isBackgroundCheckered () const
bool isDetailsButtonVisible () const
bool isEnabled () const
bool isEnabledTo (QWidget *) const
bool isEnabledToTLW () const
bool isFullScreen () const
bool isHidden () const
bool isLeftToRight () const
bool isMaximized () const
bool isMinimized () const
bool isModal () const
bool isRightToLeft () const
bool isSizeGripEnabled () const
bool isTopLevel () const
bool isVisible () const
bool isVisibleTo (QWidget *) const
bool isWidgetType () const
bool isWindow () const
bool isWindowModified () const
void killTimer (int id)
QLayoutlayout () const
Qt::LayoutDirection layoutDirection () const
QLocale locale () const
int logicalDpiX () const
int logicalDpiY () const
QPoint mapFrom (QWidget *, const QPoint &) const
QPoint mapFromGlobal (const QPoint &) const
QPoint mapFromParent (const QPoint &) const
QPoint mapTo (QWidget *, const QPoint &) const
QPoint mapToGlobal (const QPoint &) const
QPoint mapToParent (const QPoint &) const
QRegion mask () const
int maximumHeight () const
QSize maximumSize () const
int maximumWidth () const
int minimumHeight () const
QSize minimumSize () const
QSize minimumSizeHint () const
int minimumWidth () const
void move (const QPoint &)
void move (int x, int y)
void moveToThread (QThread *thread)
QWidgetnativeParentWidget () const
QWidgetnextInFocusChain () const
QRect normalGeometry () const
int numColors () const
QString objectName () const
Qt::Orientation orientation () const
void overrideWindowFlags (Qt::WindowFlags type)
void overrideWindowState (Qt::WindowStates state)
QPaintEnginepaintEngine () const
bool paintingActive () const
const QPalettepalette () const
QObjectparent () const
QWidgetparentWidget () const
int physicalDpiX () const
int physicalDpiY () const
QPoint pos () const
QVariant property (const char *name) const
 QtGradientDialog (QWidget *parent=0)
QRect rect () const
void releaseKeyboard ()
void releaseMouse ()
void releaseShortcut (int id)
void removeAction (QAction *action)
void removeEventFilter (QObject *)
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
void repaint (const QRegion &)
void repaint (const QRect &)
void repaint (int x, int y, int w, int h)
void resize (const QSize &)
void resize (int w, int h)
bool restoreGeometry (const QByteArray &geometry)
int result () const
QByteArray saveGeometry () const
void scroll (int dx, int dy, const QRect &)
void scroll (int dx, int dy)
void setAcceptDrops (bool on)
void setAccessibleDescription (const QString &description)
void setAccessibleName (const QString &name)
void setAttribute (Qt::WidgetAttribute, bool on=true)
void setAutoFillBackground (bool enabled)
void setBackgroundCheckered (bool checkered)
void setBackgroundRole (QPalette::ColorRole)
void setBaseSize (int basew, int baseh)
void setBaseSize (const QSize &)
void setContentsMargins (int left, int top, int right, int bottom)
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
void setCursor (const QCursor &)
void setDetailsButtonVisible (bool visible)
void setDetailsVisible (bool visible)
void setExtension (QWidget *extension)
void setFixedHeight (int h)
void setFixedSize (int w, int h)
void setFixedSize (const QSize &)
void setFixedWidth (int w)
void setFocus (Qt::FocusReason reason)
void setFocusPolicy (Qt::FocusPolicy policy)
void setFocusProxy (QWidget *)
void setFont (const QFont &)
void setForegroundRole (QPalette::ColorRole)
void setGeometry (const QRect &)
void setGeometry (int x, int y, int w, int h)
void setGradient (const QGradient &gradient)
void setInputContext (QInputContext *)
void setLayout (QLayout *)
void setLayoutDirection (Qt::LayoutDirection direction)
void setLocale (const QLocale &locale)
void setMask (const QRegion &)
void setMask (const QBitmap &)
void setMaximumHeight (int maxh)
void setMaximumSize (int maxw, int maxh)
void setMaximumSize (const QSize &)
void setMaximumWidth (int maxw)
void setMinimumHeight (int minh)
void setMinimumSize (int minw, int minh)
void setMinimumSize (const QSize &)
void setMinimumWidth (int minw)
void setModal (bool modal)
void setMouseTracking (bool enable)
void setObjectName (const QString &name)
void setOrientation (Qt::Orientation orientation)
void setPalette (const QPalette &)
void setParent (QObject *)
void setParent (QWidget *parent, Qt::WindowFlags f)
void setParent (QWidget *parent)
bool setProperty (const char *name, const QVariant &value)
void setResult (int r)
void setShortcutAutoRepeat (int id, bool enable=true)
void setShortcutEnabled (int id, bool enable=true)
void setSizeGripEnabled (bool)
void setSizeIncrement (int w, int h)
void setSizeIncrement (const QSize &)
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
void setSizePolicy (QSizePolicy)
void setSpec (QColor::Spec spec)
void setStatusTip (const QString &)
void setStyle (QStyle *)
void setToolTip (const QString &)
void setUpdatesEnabled (bool enable)
void setUserData (uint id, QObjectUserData *data)
void setVisible (bool visible)
void setWhatsThis (const QString &)
void setWindowFilePath (const QString &filePath)
void setWindowFlags (Qt::WindowFlags type)
void setWindowIcon (const QIcon &icon)
void setWindowIconText (const QString &)
void setWindowModality (Qt::WindowModality windowModality)
void setWindowOpacity (qreal level)
void setWindowRole (const QString &)
void setWindowState (Qt::WindowStates state)
void setWindowSurface (QWindowSurface *surface)
bool signalsBlocked () const
QSize size () const
QSize sizeHint () const
QSize sizeIncrement () const
QSizePolicy sizePolicy () const
QColor::Spec spec () const
void stackUnder (QWidget *)
int startTimer (int interval)
QString statusTip () const
QStylestyle () const
QString styleSheet () const
bool testAttribute (Qt::WidgetAttribute) const
QThreadthread () const
QString toolTip () const
QWidgettopLevelWidget () const
bool underMouse () const
void unsetCursor ()
void unsetLayoutDirection ()
void unsetLocale ()
void update (const QRegion &)
void update (const QRect &)
void update (int x, int y, int w, int h)
void updateGeometry ()
bool updatesEnabled () const
QObjectUserData * userData (uint id) const
QRegion visibleRegion () const
QString whatsThis () const
int width () const
int widthMM () const
QWidgetwindow () const
QString windowFilePath () const
Qt::WindowFlags windowFlags () const
QIcon windowIcon () const
QString windowIconText () const
Qt::WindowModality windowModality () const
qreal windowOpacity () const
QString windowRole () const
Qt::WindowStates windowState () const
QWindowSurfacewindowSurface () const
QString windowTitle () const
Qt::WindowType windowType () const
WId winId () const
int x () const
int y () const
 ~QtGradientDialog ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static QWidgetfind (WId)
static QGradient getGradient (bool *ok, QWidget *parent=0, const QString &caption=QString())
static QGradient getGradient (bool *ok, const QGradient &initial, QWidget *parent=0, const QString &caption=QString())
static QWidgetkeyboardGrabber ()
static QWidgetmouseGrabber ()
static uint registerUserData ()
static void setTabOrder (QWidget *, QWidget *)

Protected Slots

void updateMicroFocus ()

Protected Member Functions

virtual void actionEvent (QActionEvent *)
void adjustPosition (QWidget *)
virtual void changeEvent (QEvent *)
virtual void childEvent (QChildEvent *)
void closeEvent (QCloseEvent *)
virtual void connectNotify (const char *signal)
void contextMenuEvent (QContextMenuEvent *)
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
virtual void customEvent (QEvent *)
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
virtual void disconnectNotify (const char *signal)
virtual void dragEnterEvent (QDragEnterEvent *)
virtual void dragLeaveEvent (QDragLeaveEvent *)
virtual void dragMoveEvent (QDragMoveEvent *)
virtual void dropEvent (QDropEvent *)
virtual void enabledChange (bool)
virtual void enterEvent (QEvent *)
bool event (QEvent *)
bool eventFilter (QObject *, QEvent *)
virtual void focusInEvent (QFocusEvent *)
bool focusNextChild ()
virtual bool focusNextPrevChild (bool next)
virtual void focusOutEvent (QFocusEvent *)
bool focusPreviousChild ()
virtual void fontChange (const QFont &)
virtual void hideEvent (QHideEvent *)
virtual void inputMethodEvent (QInputMethodEvent *)
void keyPressEvent (QKeyEvent *)
virtual void keyReleaseEvent (QKeyEvent *)
virtual void languageChange ()
virtual void leaveEvent (QEvent *)
int metric (PaintDeviceMetric) const
virtual void mouseDoubleClickEvent (QMouseEvent *)
virtual void mouseMoveEvent (QMouseEvent *)
virtual void mousePressEvent (QMouseEvent *)
virtual void mouseReleaseEvent (QMouseEvent *)
virtual void moveEvent (QMoveEvent *)
virtual void paintEvent (QPaintEvent *)
virtual void paletteChange (const QPalette &)
int receivers (const char *signal) const
void resetInputContext ()
void resizeEvent (QResizeEvent *)
QObjectsender () const
void showEvent (QShowEvent *)
virtual void styleChange (QStyle &)
virtual void tabletEvent (QTabletEvent *)
virtual void timerEvent (QTimerEvent *)
virtual void wheelEvent (QWheelEvent *)
virtual void windowActivationChange (bool)

Protected Attributes

ushort painters

Static Protected Attributes

static const QMetaObject staticQtMetaObject

Properties

bool acceptDrops
 whether drop events are enabled for this widget
QString accessibleDescription
 the widget's description as seen by assistive technologies
QString accessibleName
 the widget's name as seen by assistive technologies
bool autoFillBackground
 whether the widget background is filled automatically
bool backgroundCheckered
 whether the background of widgets able to show the colors with alpha channel is checkered.
QSize baseSize
 the base size of the widget
QRect childrenRect
 the bounding rectangle of the widget's children
QRegion childrenRegion
 the combined region occupied by the widget's children
Qt::ContextMenuPolicy contextMenuPolicy
 how the widget shows a context menu
QCursor cursor
 the cursor shape for this widget
bool detailsButtonVisible
 whether the details button allowing for showing and hiding details extension is visible.
bool detailsVisible
 whether details extension is visible.
bool enabled
 whether the widget is enabled
bool focus
 whether this widget (or its focus proxy) has the keyboard input focus
Qt::FocusPolicy focusPolicy
 the way the widget accepts keyboard focus
QFont font
 the font currently set for the widget
QRect frameGeometry
 geometry of the widget relative to its parent including any window frame
QSize frameSize
 the size of the widget including any window frame
bool fullScreen
 whether the widget is shown in full screen mode
QRect geometry
 the geometry of the widget relative to its parent and excluding the window frame
QGradient gradient
 the gradient of the dialog
int height
 the height of the widget excluding any window frame
bool isActiveWindow
 whether this widget's window is the active window
Qt::LayoutDirection layoutDirection
 the layout direction for this widget
QLocale locale
 the widget's locale
bool maximized
 whether this widget is maximized
int maximumHeight
 the widget's maximum height in pixels
QSize maximumSize
 the widget's maximum size in pixels
int maximumWidth
 the widget's maximum width in pixels
bool minimized
 whether this widget is minimized (iconified)
int minimumHeight
 the widget's minimum height in pixels
QSize minimumSize
 the widget's minimum size
QSize minimumSizeHint
 the recommended minimum size for the widget
int minimumWidth
 the widget's minimum width in pixels
bool modal
 whether show() should pop up the dialog as modal or modeless
bool mouseTracking
 whether mouse tracking is enabled for the widget
QRect normalGeometry
 the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget
QString objectName
 the name of this object
QPalette palette
 the widget's palette
QPoint pos
 the position of the widget within its parent widget
QRect rect
 the internal geometry of the widget excluding any window frame
QSize size
 the size of the widget excluding any window frame
bool sizeGripEnabled
 whether the size grip is enabled
QSize sizeHint
 the recommended size for the widget
QSize sizeIncrement
 the size increment of the widget
QSizePolicy sizePolicy
 the default layout behavior of the widget
QString statusTip
 the widget's status tip
QString styleSheet
 the widget's style sheet
QString toolTip
 the widget's tooltip
bool updatesEnabled
 whether updates are enabled
bool visible
 whether the widget is visible
QString whatsThis
 the widget's What's This help text.
int width
 the width of the widget excluding any window frame
QString windowFilePath
 the file path associated with a widget
QIcon windowIcon
 the widget's icon
QString windowIconText
 the widget's icon text
Qt::WindowModality windowModality
 which windows are blocked by the modal widget
bool windowModified
 whether the document shown in the window has unsaved changes
double windowOpacity
 The level of opacity for the window.
QString windowTitle
 the window title (caption)
int x
 the x coordinate of the widget relative to its parent including any window frame
int y
 the y coordinate of the widget relative to its parent and including any window frame

Private Attributes

class QtGradientDialogPrivate * d_ptr

Friends

class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name)
qFindChildqFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)()
QList< T > qFindChildren (const QObject *obj, const QString &name)
QList< T > qFindChildrenqFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)()
QList< T > qFindChildrenqFindChildren (const QObject *obj, const QRegExp &regExp)()
T * qobject_cast (QObject *object)
 QObjectList
 QT_END_NAMESPACEWId
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)
const Q_GUI_EXPORT QX11Infoqt_x11Info (const QPaintDevice *pd)
 QWidgetList

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index