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

TraceCanvas QML Type

A specialized Canvas type for rendering Trace objects.

This type was introduced in QtQuick.VirtualKeyboard 2.0.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

TraceCanvas QML Type

  • Import Statement: import QtQuick.VirtualKeyboard.Styles

  • Since:: QtQuick.VirtualKeyboard 2.0

  • Inherits:: Canvas

  • Group: TraceCanvas is part of qmlclass, qtvirtualkeyboard-styles-qml

Detailed Description

This type provides capabilities for rendering Trace objects on the screen.

To make the Trace rendering available in the keyboard, this type must be declared as the KeyboardStyle.traceCanvasDelegate component.

 
Sélectionnez
traceCanvasDelegate: TraceCanvas {
}

Custom drawing attributes can be initialized in the Canvas.available signal. For example:

 
Sélectionnez
onAvailableChanged: {
    if (!available)
        return;
    var ctx = getContext("2d")
    ctx.lineWidth = 8 * scaleHint
    ctx.lineCap = "round"
    ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF)
    ctx.fillStyle = ctx.strokeStyle
}

The type offers built-in options for Trace rendering. Currently the following rendering options are available:

  • renderSmoothedLine Renders smoothed line with round corners (the default)

The rendering function can be changed with the renderFunction property.

 
Sélectionnez
renderFunction: renderSmoothedLine

Custom rendering function is also supported. Consider the following example:

 
Sélectionnez
renderFunction: renderCustomLine

function renderCustomLine() {
    getContext("2d")
    var points = trace.points()

    ...
}

Property Documentation

 

autoDestroy : bool

Enables auto destruction mode.

If enabled, this item will be destroyed when the trace object is destroyed.

The default value is false. In this case the canvas can be reused after onRecycle signal is triggered.

autoDestroyDelay : int

Specifies the approximate delay in milliseconds, counted from the beginning of the auto destruction, before the object is to be destroyed or recycled.

This delay makes it possible, for example, to animate the item before destruction.

The default value is 0.

renderFunction : var

This property defines the rendering function.

The default value is renderSmoothedLine

trace : Trace

Provides access to Trace object.

Signal Documentation

 

[since QtQuick.VirtualKeyboard.Styles 6.1] onRecycle(var traceCanvas)

Emitted when the traceCanvas is recycled.

The corresponding handler is onOnRecycle.

This signal was introduced in QtQuick.VirtualKeyboard.Styles 6.1.

Method Documentation

 

[since QtQuick.VirtualKeyboard.Styles 6.1] recycle()

Recycles trace canvas by clearing all drawings and resetting the variables.

The function triggers onRecycle signal after completed (before the return).

The function returns true when recycling is successful.

This method was introduced in QtQuick.VirtualKeyboard.Styles 6.1.

[since QtQuick.VirtualKeyboard.Styles 6.1] renderClear()

Clears screen and resets the rendering.

This method was introduced in QtQuick.VirtualKeyboard.Styles 6.1.

renderSmoothedLine()

Renders smoothed line with round corners.

This function is incremental and renders only the new part added to the Trace.

This function does not alter any of the canvas attributes (i.e. they can be set elsewhere.)

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