QML Tumbler with sprite or SpriteSequence - qt

I use to call following function jumpTo() to change a sprite in sprite sequence, but it use to change the sprite abruptly.
Is it possible to animate when i call function ... digit.jumpTo(n); ... to animate sprites to scroll up ?
Or Can i use sprite's with a tumbler ?
import QtQuick 2.0
Item {
id: numberImageSprite
//anchors.centerIn: parent
width: 20
height: 20
SpriteSequence {
id: digit
width: 12
height: 16
interpolate: false
goalSprite: ""
running: true
property var sourceImage: 'files/abc.png'
Sprite{
name: "0"
source: digit.sourceImage
frameCount: 1
frameWidth: 10
frameHeight: 16
frameX: 0
frameY: 0
}
Sprite{
name: "1"
source: digit.sourceImage
frameCount: 1
frameWidth: 9
frameHeight: 16
frameX: 12
frameY: 0
}
}
function setNumber(n){
digit.jumpTo(n);
}
}

You can forget about Sprites when you want to use Tumbler. You can use the Image in your delegate. Here is a working example. I added -/+ buttons for you to see how manually you can rotate the Tumbler.
Item{
id: itm
anchors.fill: parent
Row{
Button{
width: 36
text: '-'
onClicked: digitsTumbler.currentIndex = digitsTumbler.currentIndex == 0 ? digitsTumbler.count-1 : digitsTumbler.currentIndex-1;
}
Tumbler {
id: digitsTumbler
model: 10
visibleItemCount: 1
height: 36
width: 36
delegate: Item{
width: 36
height: 36
clip: true
Image{
x:0
y:0
sourceSize: Qt.size(360,36)
source: "qrc:///d.png"
transform: Translate{x: index*-36 ; y:0}
}
}
}
Button{
width: 36
text: '+'
onClicked: digitsTumbler.currentIndex = digitsTumbler.currentIndex == digitsTumbler.count-1 ? 0 : digitsTumbler.currentIndex+1;
}
}
}
d.png is attached as a sample image containing digits from 0 to 9.

Related

QML Keep transition during the x seconds on mousearea Pressed once

I checked the different mouseArea events in the documentation and there is no chance to execute a function while a mouseArea is being pressed once. I want to keep the transition for 5 seconds and after 5 seconds it should out back.
Here is what i'm trying
Rectangle {
id: bottomBar
x: 0
y: 431
width: 800
height: 100
visible: true
color: "#d0e8f5"
radius: 32
border.width: 0
clip: false
MouseArea {
id: mouseArea
anchors.fill: parent
}
states: State {
name: "moved"; when: mouseArea.pressed
PropertyChanges { target: bottomBar; x: 0; y: 411}
}
transitions: Transition {
NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; }
}
}
i want to keep bottomBar on x:0 y:411 for 5 seconds
Thanks to #iam_peter we figured out the solution. I share the solution below. I also added 2 rowlayouts on this bottomBar and wanted to have 4 images with good alignment and i did. Now i want to make this images clickable and bring the ui to another qmls.(i am using stack view for that)
property string initializePage : "MainMenu.qml"
property string lightningPage : "LightningMenu.qml"
property string timerPage : "Timer.qml"
Rectangle {
id: bottomBar
x: 0
y: 431
width: 800
height: 100
visible: true
color: "#d0e8f5"
radius: 32
border.width: 0
clip: false
MouseArea {
id: mouseArea
anchors.fill: parent
onPressed: SequentialAnimation {
PropertyAnimation {
target: bottomBar
property: "y"
to: 411
}
PropertyAnimation {
targets: [bottomRowLeft,bottomRowRight]
property: "opacity"
to: 1
}
PauseAnimation {
duration: 5000
}
PropertyAnimation {
targets: [bottomRowLeft,bottomRowRight]
property: "opacity"
to: 0
}
PropertyAnimation {
target: bottomBar
property: "y"
to: 431
}
}
}
}
RowLayout{
id: bottomRowLeft
anchors {
left: bottomBar.left
bottom: bottomBar.bottom
}
anchors.bottomMargin: 45
anchors.leftMargin: 175
spacing: 10
opacity: 0
//Home Icon
Image{
source: "/images/homeButtonIcon.png"
}
MouseArea{
id: homeClicked
Layout.fillWidth: true
onClicked: {
stackViewTool.replace(Qt.resolvedUrl("MainMenu.qml")) // not working
}
}
Image{
source:"/images/removeButtonIcon.png"
}
MouseArea{
id: removeClicked
Layout.fillWidth: true
}
}
RowLayout{
id: bottomRowRight
anchors {
left: bottomRowLeft.right
bottom: bottomBar.bottom
}
anchors.bottomMargin: 45
anchors.leftMargin: 215
spacing: 10
opacity: 0
//Home Icon
Image{
source: "/images/cancelButtonIcon.png"
}
MouseArea{
id: cancelClicked
Layout.fillWidth: true
}
Image{
source:"/images/applyButtonIcon.png"
}
MouseArea{
id: applyClicked
Layout.fillWidth: true
onClicked: {
stackViewTool.replace(lightningPage)
}
}
}
StackView {
id: stackViewTool
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: bottomBar.top
}
initialItem: initializePage
}
You want to trigger an animation on MouseArea press, then the property should change, pause and go back to the previous value?
Rectangle {
id: bottomBar
x: 0
y: 431
width: 800
height: 100
visible: true
color: "#d0e8f5"
radius: 32
border.width: 0
clip: false
MouseArea {
id: mouseArea
anchors.fill: parent
onPressed: SequentialAnimation {
PropertyAnimation {
target: bottomBar
property: "y"
to: 411
}
PauseAnimation {
duration: 5000
}
PropertyAnimation {
target: bottomBar
property: "y"
to: 431
}
}
}
}
The issue on your example is that the MouseArea isn't filling the Image you should use anchors.fill and make the MouseArea a child of the Image. Currently it is also layouted by the RowLayout which you might want but doesn't make sense if you want to make the images button-like. I came up with this solution which might be what you want. This is just a guess.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
id: root
color: "white"
width: 800
height: 600
visible: true
component SimplePage: Rectangle {
property alias name: pageText.text
width: root.width
height: 200
color: "lightgrey"
Text {
id: pageText
anchors.centerIn: parent
font.pixelSize: 40
}
}
component SimpleButton: Rectangle {
property alias letter: buttonText.text
signal clicked
color: "grey"
width: 40
height: 40
Text {
id: buttonText
anchors.centerIn: parent
font {
pixelSize: 20
bold: true
}
}
MouseArea {
anchors.fill: parent
onClicked: parent.clicked()
}
}
Component {
id: initializePage
SimplePage { name: "initialize" }
}
Component {
id: lightningPage
SimplePage { name: "lightning" }
}
Component {
id: timerPage
SimplePage { name: "timer" }
}
Rectangle {
id: bottomBar
x: 0
y: 431
width: 800
height: 100
visible: true
color: "#d0e8f5"
radius: 32
border.width: 0
clip: false
MouseArea {
id: mouseArea
anchors.fill: parent
onPressed: SequentialAnimation {
PropertyAnimation {
target: bottomBar
property: "y"
to: 411
}
PropertyAnimation {
targets: [bottomRowLeft,bottomRowRight]
property: "opacity"
to: 1
}
PauseAnimation {
duration: 5000
}
PropertyAnimation {
targets: [bottomRowLeft,bottomRowRight]
property: "opacity"
to: 0
}
PropertyAnimation {
target: bottomBar
property: "y"
to: 431
}
}
}
}
RowLayout {
id: bottomRowLeft
anchors {
left: bottomBar.left
bottom: bottomBar.bottom
}
anchors.bottomMargin: 45
anchors.leftMargin: 175
spacing: 10
opacity: 0
// Home
SimpleButton {
letter: "H"
onClicked: stackViewTool.replace(initializePage)
}
// Remove
SimpleButton {
letter: "R"
}
}
RowLayout {
id: bottomRowRight
anchors {
left: bottomRowLeft.right
bottom: bottomBar.bottom
}
anchors.bottomMargin: 45
anchors.leftMargin: 215
spacing: 10
opacity: 0
// Cancel
SimpleButton {
letter: "C"
}
// Apply
SimpleButton {
letter: "A"
onClicked: stackViewTool.replace(lightningPage)
}
}
StackView {
id: stackViewTool
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: bottomBar.top
}
initialItem: initializePage
}
}
I made the following changes to your example:
Use a Page control
Put the toolbar in the footer section
Use Frame and RowLayout for the toolbar
Refactored AppButton.qml for a clickable icon Button
Supplied mock MainPage.qml and LightningPage.qml
Supply mock SVG assets
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Page {
StackView {
id: stackView
anchors.fill: parent
initialItem: "MainPage.qml"
}
footer: Frame {
background: Rectangle { color: "#d0e8f5" }
RowLayout {
AppButton {
icon.source: "home-32.svg"
onClicked: stackView.replace("MainPage.qml")
}
AppButton {
icon.source: "x-circle-32.svg"
}
AppButton {
icon.source: "thumbs-up-32.svg"
onClicked: stackView.replace("LightningPage.qml")
}
}
}
}
// MainPage.qml
import QtQuick
import QtQuick.Controls
Page {
Text {
anchors.centerIn: parent
text: qsTr("MainPage.qml")
}
}
// LightningPage.qml
import QtQuick
import QtQuick.Controls
Page {
Text {
anchors.centerIn: parent
text: qsTr("LightningPage.qml")
}
}
// AppButton.qml
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Button {
Layout.preferredWidth: 64
Layout.preferredHeight: 64
background: Rectangle {
radius: 8
border.color: focused ? pressed ? "white" : "black" : "grey"
color: pressed ? "lightsteelblue" : "#ccc"
}
icon.color: pressed ? "white" : "black"
icon.width: 32
icon.height: 32
}
// home-32.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M11 8.5V5H6v8.5L2.5 17H5v12h8v-8h6v8h8V17h2.5L16 3.5zM26 16v12h-6v-8h-8v8H6V16H4.914L7 13.914V6h3v4.914l6-6L27.086 16z"/><path fill="none" d="M0 0h32v32H0z"/></svg>
// thumbs-up-32.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M29.878 13.966A2.564 2.564 0 0 0 27.422 12h-4.61a12.784 12.784 0 0 1-1.447-.054 4.48 4.48 0 0 1 .078-.083c.063-.051 1.522-1.33 1.522-4.903 0-2.832-.52-4.436-1.591-4.904a2.336 2.336 0 0 0-2.283.577l-.16.148L18.93 3a9.143 9.143 0 0 1-1.608 4.53 12.855 12.855 0 0 1-3.396 3.745L10.78 16H9v-2H3v15h6v-2h2.767l3.363 2h9.664a2.807 2.807 0 0 0 2.534-1.58 2.586 2.586 0 0 0 .069-2.196 2.683 2.683 0 0 0 1.464-1.773 2.773 2.773 0 0 0-.42-2.298 2.873 2.873 0 0 0 1.303-1.938 2.754 2.754 0 0 0-.653-2.22 3.037 3.037 0 0 0 .787-3.03zM8 28H4V15h4zm20.073-11.477l-.582.364.525.442a1.889 1.889 0 0 1 .74 1.73 2.006 2.006 0 0 1-1.299 1.487l-.748.305.605.533a1.786 1.786 0 0 1 .58 1.814 1.725 1.725 0 0 1-1.342 1.261l-.776.167.485.628a1.589 1.589 0 0 1 .17 1.725A1.813 1.813 0 0 1 24.794 28h-9.389l-3.363-2H9v-9h2.32l3.255-4.96a13.852 13.852 0 0 0 3.58-3.957 10.348 10.348 0 0 0 1.764-4.833 1.222 1.222 0 0 1 1.055-.278c.298.13.99.78.99 3.988 0 3.06-1.16 4.135-1.197 4.169-.194.193-.705.706-.483 1.244.25.599 1.037.627 2.528.627h4.61a1.58 1.58 0 0 1 1.495 1.241 1.99 1.99 0 0 1-.844 2.282z"/><path fill="none" d="M0 0h32v32H0z"/></svg>
// x-circle-32.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M22.864 10.843L17.207 16.5l5.657 5.657-.707.707-5.657-5.657-5.657 5.657-.707-.707 5.657-5.657-5.657-5.657.707-.707 5.657 5.657 5.657-5.657zM29.8 16.5A13.3 13.3 0 1 1 16.5 3.2a13.3 13.3 0 0 1 13.3 13.3zm-1 0a12.3 12.3 0 1 0-12.3 12.3 12.314 12.314 0 0 0 12.3-12.3z"/><path fill="none" d="M0 0h32v32H0z"/></svg>
You can Try it Online!

How do I add a point on QML Maps by typing in coordinates?

I want to add a point on my map by typing in the coordinates. It's working fine, but I can't covert my input to actual map coordinates. It's taking the value of the screen and converting that to the coordinate.
For example, if I type in (0,0) it puts the point on the (0,0) screen position, which is the coordinate (78.46671909721232, -74.02100401110448). I check this with the console.log output. How do I ask it to put a point on (0,0) longitude/latitude?
I've added the code below for reference.
TextField {
id: xcoordtext
anchors.verticalCenter: parent.verticalCenter
validator: DoubleValidator {bottom: -90.00; top: 90.00;}
Layout.fillWidth: true
}
TextField {
id: ycoordtext
anchors.verticalCenter: parent.verticalCenter
validator: DoubleValidator {bottom: -90.00; top: 90.00;}
Layout.fillWidth: true
}
Button {
text: "POINT Confirmed"
Layout.fillWidth: true
onClicked: {
var waypointCoord = myMap.toCoordinate(Qt.point(xcoordtext.text,ycoordtext.text), false)
console.log(waypointCoord.longitude, waypointCoord.latitude)
}
}
The error and message that is coming in the console log is as follows:-
"Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
"This will throw a JavaScript TypeError in future releases of Qt!"
qml: -106.9871520804946 79.58494957851264
Ignored NaN, Inf, or -Inf value.
Attempting to set invalid range for value axis: [ nan - nan ]
TerrainQueryLog: Error in fetching elevation tile. Empty response.
Ignored NaN, Inf, or -Inf value.
Attempting to set invalid range for value axis: [ nan - nan ]
Where qml: -106.9871520804946 79.58494957851264 are the coordinates I get when I type in 0 (xcoordtext.text) and 0(ycoord.text) in the TextField inputs.
I write this Example for you , as I understand from your question.
if you want that user adds lat and long in TextInput and then add a point on this coordinate you shouldn't convert anything.
I use TextInput instead of TextField to getting user input.
in this example, user add x and y number from -90 to 90 and in map add that point by red circle.
in the bottom right of the screen I put a white rect that shows mouse position in lat and long in this , I convert screen x and y to lat and long .
as you can see the differences, and also you can see that mouse that points to the red circle show exactly the point that the user adds from text input .
import QtQuick 2.0
import QtLocation 5.9
import QtPositioning 5.8
import QtQuick.Controls 2.12
Item {
Plugin
{
id: mapPlugin
name: "osm"
}
Map
{
id: map
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.leftMargin: 0
anchors.topMargin: 0
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(29.7264175,55.99735)
zoomLevel: 5
copyrightsVisible: false
focus: true
MouseArea
{
anchors.fill: map
hoverEnabled: true
onPositionChanged: {
lat.text ="Lat :"+ map.toCoordinate(Qt.point(mouseX,mouseY)).latitude.toString()
lon.text ="Lon :"+ map.toCoordinate(Qt.point(mouseX,mouseY)).longitude.toString()
}
}
property Component itemDelegate: Component{
Rectangle {
width: 14
height: 14
radius: 7
color: "red"
}
}
MapItemView{
id: item_view
model: ListModel{
id: item_model
}
delegate: MapQuickItem{
id: ietm_delegate
zoomLevel: 0
sourceItem: Loader{
sourceComponent: map.itemDelegate
}
coordinate{
latitude: latitudeval
longitude: longitudeval
}
anchorPoint: Qt.point(sourceItem.width/2, sourceItem.height/2)
}
}
Rectangle
{
width: 251
height: 163
color: "#ffffff"
border.color: "#000000"
border.width: 1
TextInput {
id: textInput_x
x: 68
y: 25
width: 175
height: 30
font.pixelSize: 16
validator: DoubleValidator {bottom: -90.00; top: 90.00;}
focus: true
}
TextInput {
id: textInput_y
x: 68
y: 60
width: 175
height: 24
font.pixelSize: 16
focus: true
validator: DoubleValidator {bottom: -90.00; top: 90.00;}
}
Label {
id: label
x: 20
y: 25
width: 53
height: 30
text: qsTr("x :")
horizontalAlignment: Text.AlignHCenter
}
Label {
id: label1
x: 20
y: 60
width: 53
height: 30
text: qsTr("Y :")
horizontalAlignment: Text.AlignHCenter
}
Button {
x: 8
y: 113
text: "POINT Confirmed"
Layout.fillWidth: true
onClicked: {
var waypointCoord = map.toCoordinate(Qt.point(textInput_x.text,textInput_y.text))
item_model.append({"latitudeval":textInput_y.text,"longitudeval":textInput_x.text});
console.log(waypointCoord.longitude, waypointCoord.latitude)
}
}
}
Rectangle {
width: 206
height: 50
color: "white"
anchors.top: parent.bottom
anchors.topMargin: -50
anchors.left: parent.right
anchors.leftMargin: -206
Text {
id: lat
width: 206
height: 24
}
Text {
id: lon
x: 0
y: 24
width: 206
height: 26
}
}
}
}

Spin box only works when up/down indicators are clicked, it does NOT works when it is edited by entering numbers

I have this Qt QML spinbox:
The problem is, it actually changes value only when up/down (+/-) indicators are clicked. When edited by entering numbers into spinbox, it does NOT change value. I have tried many things, but I cannot figure out why. Can anybody help?
QML code of the spinbox is this:
StyledSpinBox {
id: overhangAngleFactorSpinBox
implicitWidth: 120
implicitHeight: 30
to: 1 * 100
stepSize: 1
from: 0
Layout.leftMargin: 8
contentItem: StyledTextInput {
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
value: 70
property int decimals: 2
property real realValue: value / 100.0
validator: DoubleValidator {
bottom: Math.min(overhangAngleFactorSpinBox.from, overhangAngleFactorSpinBox.to)
top: Math.max(overhangAngleFactorSpinBox.from, overhangAngleFactorSpinBox.to)
}
textFromValue: function(value, locale) {
return Number(value / 100.0).toLocaleString(locale, 'f', overhangAngleFactorSpinBox.decimals)
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * 100.0
}
onValueChanged: {
editorScene.overhangAngleFactor = value / 100.0
}
}
StyledSpinBox.qml contains:
import QtQuick 2.5
import QtQuick.Controls 2.0 as QQC2
QQC2.SpinBox {
id: control
font.family: editorContent.labelFontFamily
font.weight: editorContent.labelFontWeight
font.pixelSize: editorContent.labelFontPixelSize
background: Rectangle {
border.color: editorContent.listHighlightColor
color: editorContent.paneBackgroundColor
}
down.indicator: Rectangle {
x: control.mirrored ? parent.width - width : 0
height: parent.height
implicitWidth: 40
implicitHeight: 40
border.color: editorContent.listHighlightColor
color: editorContent.listHighlightColor
Image {
anchors.centerIn: parent
source: "images/spinbox_down.png"
}
}
up.indicator: Rectangle {
x: control.mirrored ? 0 : parent.width - width
height: parent.height
implicitWidth: 40
implicitHeight: 40
border.color: editorContent.listHighlightColor
color: editorContent.listHighlightColor
Image {
anchors.centerIn: parent
source: "images/spinbox_up.png"
}
}
}
Problem solved by adding editable: true to spin box. According to documentation, the default value for editable is false:
editable : bool
This property holds whether the spinbox is editable. The default value is false.

How to implement curved scrollview in qml?

How to get the look of curved Scroll bar/scroll view as shown below in QML with Label or TextArea?
Basically this application is not a touch application.
Environment, Qt 5.7.0 in Linux.
You can use PathInterpolator from Controls.2. The example below is some Slider modification, you can adopt it for your needs:
import QtQuick 2.9
import QtQuick.Controls 2.2
ApplicationWindow {
id: mainWindow
visible: true
width: 400
height: 400
Path {
id: myPath
startX: 0; startY: 20
PathCurve { x: 100; y: 40 }
PathCurve { x: 200; y: 10 }
PathCurve { x: 300; y: 40 }
}
Slider {
id: control
width: 300
height: 50
anchors.centerIn: parent
background: Rectangle {
anchors.fill: parent
color: "orange"
Canvas {
anchors.fill: parent
contextType: "2d"
onPaint: {
context.strokeStyle = "MediumPurple";
context.path = myPath;
context.stroke();
}
}
PathInterpolator {
id: motionPath
path: myPath
progress: control.visualPosition
}
}
handle: Rectangle {
width: 30
height: 30
radius: 15
color: "DodgerBlue"
x: motionPath.x - 15
y: motionPath.y - 15
}
}
}
You can use a Flickable to have your view. To this Flickable you attatch a ScrollBar which you can style.
To style this ScrollBar is a bit tricky, for some of its properties are bullshit.
The position-property, which is documented as
This property holds the position of the scroll bar, scaled to 0.0 - 1.0.
will never reach 1.0 unless, the handles size is 0. You don't really have the ability to set the size of the handle, though. It will be automatically resized. So if you don't want to have a handle that fills the width of the ScrollBar entirely, you need to use a Item as a base and add a the visual inside this, so you have the sovereignity again.
All together, it might look like this:
Flickable {
anchors.fill: parent
contentWidth: width
contentHeight: mainWindow.height * 10
Rectangle {
width: 640
height: mainWindow.height * 10
gradient: Gradient {
GradientStop { color: 'orchid'; position: 0 }
GradientStop { color: 'orange'; position: 1 }
}
}
ScrollBar.vertical: ScrollBar {
id: scrollBar
width: 50
contentItem: Item {
// This will deal with the bullshit of the position. Imperfect, as I do not consider any margins/paddings
property real normalizedPosition: scrollBar.position * (scrollBar.height / (scrollBar.height - height))
Rectangle {
// Draw the curve by defining a function for x in dependance of the position.
x: Math.sin(Math.PI * parent.normalizedPosition) * 40
width: 10
height: parent.height // I use the default height, so it
// really goes from top to bottom.
// A smaller height means, you should
// also alter the y value to have a
// more natural behavior.
radius: 5
color: 'green'
Text {
text: parent.parent.normalizedPosition
}
}
}
}
}

QML slider tickmark with text at start and end

How to achieve something like this.
Should the text thin and thick must be outside slider as labels or can they be part of tickmarks?
That can be easily done with styles. I advice you to look at QML controls/styles source in $QTHOME/qml/QtQuick/Controls[/Styles/Base] to have an understanding of default styles of QML controls.
import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
Window {
id: rootWindow
visible: true
height: 800
width: 800
Rectangle {
width: 350
height: 100
color: "#555"
anchors.centerIn: parent
Slider {
anchors.centerIn: parent
minimumValue: 1
maximumValue: 5
stepSize: 1
tickmarksEnabled: true
width: 300
style: SliderStyle {
handle: Rectangle {
width: 18
height: 30
border.width: 2
border.color: "#555"
color: "#CCC"
radius: 5
}
groove: Rectangle {
height: 15
width: parent.width
anchors.verticalCenter: parent.verticalCenter
color: "#CCC"
}
tickmarks: Repeater {
id: repeater
model: control.stepSize > 0 ? 1 + (control.maximumValue - control.minimumValue) / control.stepSize : 0
Item {
Text {
y: repeater.height + 5
width : repeater.width / repeater.count
x: width * index
height: 30
color: "#CCC"
font.pixelSize: 20
text: getText()
horizontalAlignment: getAlign()
function getText() {
if(index === 0) return "THIN"
else if(index === repeater.count - 1) return "THICK"
else return "";
}
function getAlign() {
if(index === "0") return Text.AlignLeft
else if(index === repeater.count - 1) return Text.AlignRight
else return Text.AlignHCenter;
}
}
Rectangle {
color: "#CCC"
width: 2 ; height: 5
y: repeater.height
x: styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))
}
}
}
}
}
}
}
The exampe is full of excessive and worthless code but that's good for understanding.
It doesn't seem like they can be a part of the tick marks, but you can easily achieve this with separate text labels:
Slider {
id: slide
width: 200
}
Text {
text: "THIN"
anchors.top: slide.bottom
anchors.left: slide.left
}
Text {
text: "THICK"
anchors.top: slide.bottom
anchors.right: slide.right
}

Resources