本文主要是介绍Qt/QML学习-Slider,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
QML学习
- Slider例程
- 视频讲解
- 代码
main.qml
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15Window {width: 640height: 480visible: truetitle: qsTr("Hello World")Slider {id: sliderfrom: 0to: 100value: 50handle: Rectangle {implicitWidth: 30implicitHeight: 30border.width: 1x: slider.leftPadding+ slider.visualPosition* (slider.availableWidth - width)y: slider.height / 2 - height / 2Text {anchors.centerIn: parentfont.pointSize: 15text: slider.value.toFixed(0)}}background: Rectangle {implicitWidth: 200implicitHeight: 40border.width: 1Rectangle {width: parent.width - slider.leftPadding- slider.rightPaddingheight: 10radius: 5anchors.centerIn: parentcolor: "black"}Rectangle {x: slider.leftPaddingwidth: slider.visualPosition * parent.width- x - slider.rightPaddingheight: 10radius: 5anchors.verticalCenter: parent.verticalCentercolor: "red"}}}
}
演示
视频讲解
这篇关于Qt/QML学习-Slider的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!