IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Slider QML Type

Used to select a value by sliding a handle along a track.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Slider QML Type

  • Import Statement: import QtQuick.Controls

  • Inherits: Control

  • Group: Slider is part of qtquickcontrols-input

Detailed Description

Image non disponible

Slider is used to select a value by sliding a handle along a track.

In the example below, custom from, value, and to values are set:

 
Sélectionnez
Slider {
    from: 1
    value: 25
    to: 100
}

The position property is expressed as a fraction of the control's size, in the range 0.0 - 1.0. The visualPosition property is the same, except that it is reversed in a right-to-left application. The visualPosition is useful for positioning the handle when styling Slider. In the example above, visualPosition will be 0.24 in a left-to-right application, and 0.76 in a right-to-left application.

For a slider that allows the user to select a range by providing two handles, see RangeSlider.

See Also

Property Documentation

 

from : real

This property holds the starting value for the range. The default value is 0.0.

See Also

See also to, value

handle : Item

This property holds the handle item.

See Also

[read-only, since QtQuick.Controls 2.3 (Qt 5.10)] horizontal : bool

This property holds whether the slider is horizontal.

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See Also

See also orientation

[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitHandleHeight : real

This property holds the implicit handle height.

The value is equal to handle ? handle.implicitHeight : 0.

This is typically used, together with implicitContentHeight and implicitBackgroundHeight, to calculate the implicitHeight.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See Also

[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitHandleWidth : real

This property holds the implicit handle width.

The value is equal to handle ? handle.implicitWidth : 0.

This is typically used, together with implicitContentWidth and implicitBackgroundWidth, to calculate the implicitWidth.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See Also

[since QtQuick.Controls 2.2 (Qt 5.9)] live : bool

This property holds whether the slider provides live updates for the value property while the handle is dragged.

The default value is true.

This property was introduced in QtQuick.Controls 2.2 (Qt 5.9).

See Also

See also value, valueAt()

orientation : enumeration

This property holds the orientation.

Possible values:

Constant

Description

Qt.Horizontal

Horizontal (default)

Qt.Vertical

Vertical

See Also

See also horizontal, vertical

[read-only] position : real

This property holds the logical position of the handle.

The position is expressed as a fraction of the control's size, in the range 0.0 - 1.0. For visualizing a slider, the right-to-left aware visualPosition should be used instead.

See Also

pressed : bool

This property holds whether the slider is pressed by either touch, mouse, or keys.

snapMode : enumeration

This property holds the snap mode.

The snap mode determines how the slider handle behaves with regards to the stepSize.

Possible values:

Constant

Description

Slider.NoSnap

The slider does not snap (default).

Slider.SnapAlways

The slider snaps while the handle is dragged.

Slider.SnapOnRelease

The slider does not snap while being dragged, but only after the handle is released.

In the following table, the various modes are illustrated with animations. The movement of the mouse cursor and the stepSize (0.2) are identical in each animation.

Value

Example

Slider.NoSnap

Image non disponible

Slider.SnapAlways

Image non disponible

Slider.SnapOnRelease

Image non disponible
See Also

See also stepSize

stepSize : real

This property holds the step size. The default value is 0.0.

See Also

See also snapMode, increase(), decrease()

to : real

This property holds the end value for the range. The default value is 1.0.

See Also

See also from, value

[since QtQuick.Controls 2.5 (Qt 5.12)] touchDragThreshold : qreal

This property holds the threshold (in logical pixels) at which a touch drag event will be initiated. The mouse drag threshold won't be affected. The default value is Qt.styleHints.startDragDistance.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See Also

See also QStyleHints

value : real

This property holds the value in the range from - to. The default value is 0.0.

See Also

See also position

[read-only, since QtQuick.Controls 2.3 (Qt 5.10)] vertical : bool

This property holds whether the slider is vertical.

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See Also

See also orientation

[read-only] visualPosition : real

This property holds the visual position of the handle.

The position is expressed as a fraction of the control's size, in the range 0.0 - 1.0. When the control is mirrored, the value is equal to 1.0 - position. This makes the value suitable for visualizing the slider, taking right-to-left support into account.

See Also

See also position

Signal Documentation

 

[since QtQuick.Controls 2.2 (Qt 5.9)] moved()

This signal is emitted when the slider has been interactively moved by the user by either touch, mouse, wheel, or keys.

The corresponding handler is onMoved.

This signal was introduced in QtQuick.Controls 2.2 (Qt 5.9).

Method Documentation

 

void decrease()

Decreases the value by stepSize or 0.1 if stepSize is not defined.

See Also

See also stepSize

void increase()

Increases the value by stepSize or 0.1 if stepSize is not defined.

See Also

See also stepSize

[since QtQuick.Controls 2.1 (Qt 5.8)] real valueAt(real position)

Returns the value for the given position.

This method was introduced in QtQuick.Controls 2.1 (Qt 5.8).

See Also

See also value, position

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+