Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QtGradientDialog Class

The QtGradientDialog class provides a dialog for specifying gradients. More...

 #include <QtGradientDialog>

Inherits: QDialog.

Public Types

enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }

Properties

  • 2 properties inherited from QDialog
  • 58 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

QtGradientDialog(QWidget * parent = 0)
virtual ~QPaintDevice()
~QtGradientDialog()
int colorCount() const
int depth() const
bool detailsVisible() const
QGradient gradient() const
int height() const
int heightMM() const
bool isBackgroundCheckered() const
bool isDetailsButtonVisible() const
int logicalDpiX() const
int logicalDpiY() const
virtual QPaintEngine * paintEngine() const = 0
bool paintingActive() const
int physicalDpiX() const
int physicalDpiY() const
void setBackgroundCheckered(bool checkered)
void setDetailsButtonVisible(bool visible)
void setDetailsVisible(bool visible)
void setGradient(const QGradient & gradient)
void setSpec(QColor::Spec spec)
QColor::Spec spec() const
int width() const
int widthMM() const
  • 8 public functions inherited from QDialog
  • 215 public functions inherited from QWidget
  • 31 public functions inherited from QObject

Static Public Members

QGradient getGradient(bool * ok, const QGradient & initial, QWidget * parent = 0, const QString & caption = QString())
QGradient getGradient(bool * ok, QWidget * parent = 0, const QString & caption = QString())
  • 4 static public members inherited from QWidget
  • 11 static public members inherited from QObject

Protected Functions

QPaintDevice()
virtual void init(QPainter * painter) const
virtual int metric(PaintDeviceMetric metric) const
virtual QPaintDevice * redirected(QPoint * offset) const
virtual QPainter * sharedPainter() const
  • 7 protected functions inherited from QDialog
  • 37 protected functions inherited from QWidget
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 5 public slots inherited from QDialog
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 3 signal inherited from QDialog
  • 1 signal inherited from QWidget
  • 2 signal inherited from QObject
  • 1 protected slot inherited from QWidget

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.

[Missing image qtgradientdialog.png][Missing image qtgradientdialogextension.png]
Details extension hiddenDetails extension visible

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

[Missing image qtgradientdialogtopbuttons.png]

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.

[Missing image qtgradientdialoglineareditor.png][Missing image qtgradientdialogradialeditor.png][Missing image qtgradientdialogconicaleditor.png]
Editing linear typeEditing radial typeEditing 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.

[Missing image qtgradientdialogstops.png][Missing image 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.

[Missing image qtgradientdialogcolorhsv.png][Missing image 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.:

     bool ok;
     QGradient gradient = QtGradientDialog::getGradient(&ok, QRadialGradient(), this);
     if (ok) {
         // the user clicked OK and gradient is set to the gradient the user selected
     } else {
         // the user canceled the dialog; gradient is set to the initial
         // value, in this case radial gradient
     }

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

     bool detailsVisible;
     QColor::Spec spec;
     QGradient gradient;

     QtGradientDialog dlg(this);
     dlg.setDetailsVisible(detailsVisible);
     dlg.setSpec(spec);
     dlg.setGradient(gradient);
     if (dlg.exec() != QDialog::Accepted)
         return;

     gradient = dlg.gradient();
     // detailsVisible and spec properties can be changed interactively by the user too,
     // we store the values of these properties for the next time QtGradientDialog is executed.
     detailsVisible = dlg.detailsVisible();
     spec = dlg.spec();

See also Gradient View Example.

Property Documentation

backgroundCheckered : bool

This property holds whether the background of widgets able to show the colors with alpha channel is checkered.

[Missing image qtgradientdialogbackgroundcheckered.png][Missing image qtgradientdialogbackgroundtransparent.png]
         QtGradientDialog dlg;
         dlg.setBackgroundCheckered(true);
         QtGradientDialog dlg;
         dlg.setBackgroundCheckered(false);

When this property is set to true (the default) widgets inside gradient dialog like color button, color sliders, gradient stops editor and gradient editor will show checkered background in case of transparent colors. Otherwise the background of these widgets is transparent.

Access functions:

bool isBackgroundCheckered() const
void setBackgroundCheckered(bool checkered)

detailsButtonVisible : bool

This property holds whether the details button allowing for showing and hiding details extension is visible.

When this property is set to true (the default) the details button is visible and the user can show and hide details extension interactively. Otherwise the button is hidden and the details extension is always visible or hidded depending on the value of detailsVisible property.

Access functions:

bool isDetailsButtonVisible() const
void setDetailsButtonVisible(bool visible)

See also detailsVisible.

detailsVisible : bool

This property holds whether details extension is visible.

When this property is set to true the details extension is visible. By default this property is set to false and the details extension is hidden.

Access functions:

bool detailsVisible() const
void setDetailsVisible(bool visible)

See also detailsButtonVisible.

gradient : QGradient

This property holds the gradient of the dialog.

Access functions:

QGradient gradient() const
void setGradient(const QGradient & gradient)

Member Function Documentation

QtGradientDialog::QtGradientDialog(QWidget * parent = 0)

Constructs a gradient dialog with parent as parent widget.

QtGradientDialog::~QtGradientDialog()

Destroys the gradient dialog

QGradient QtGradientDialog::getGradient(bool * ok, const QGradient & initial, QWidget * parent = 0, const QString & caption = QString()) [static]

Executes a modal gradient dialog, lets the user to specify a gradient, and returns that gradient.

If the user clicks OK, the gradient specified by the user is returned. If the user clicks Cancel, the initial gradient is returned.

The dialog is constructed with the given parent. caption is shown as the window title of the dialog and initial is the initial gradient shown in the dialog. If the ok parameter is not-null, the value it refers to is set to true if the user clicks OK, and set to false if the user clicks Cancel.

QGradient QtGradientDialog::getGradient(bool * ok, QWidget * parent = 0, const QString & caption = QString()) [static]

This method calls getGradient(ok, QLinearGradient(), parent, caption).

void QtGradientDialog::setSpec(QColor::Spec spec)

Sets the current QColor::Spec to spec used for the color sliders in the dialog.

See also spec().

QColor::Spec QtGradientDialog::spec() const

Returns the current QColor::Spec used for the color sliders in the dialog.

See also setSpec().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web