美文网首页
Flat风格的Qml滑动条

Flat风格的Qml滑动条

作者: Qt君 | 来源:发表于2019-12-14 22:48 被阅读0次

基于Qml的Slider控件修改而成。

demo.gif

滑动条代码

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0

Slider {
    id: root

    property color checkedColor: "#3498DB"

    value: 0.5

    background: Rectangle {
        x: root.leftPadding
        y: root.topPadding + root.availableHeight / 2 - height / 2
        implicitWidth: 200
        implicitHeight: 12
        width: root.availableWidth
        height: implicitHeight
        radius: height / 2
        color: "#EBEDEF"

        Rectangle {
            width: root.visualPosition == 0 ? 0 : root.handle.x + root.handle.width / 2
            height: parent.height
            color: root.checkedColor
            radius: height / 2


            layer.enabled: root.hovered | root.pressed
            layer.effect: DropShadow {
                transparentBorder: true
                color: root.checkedColor
                samples: 8
            }
        }
    }

    handle: Rectangle {
        x: root.leftPadding + root.visualPosition * (root.availableWidth - width)
        y: root.topPadding + root.availableHeight / 2 - height / 2
        implicitWidth: root.background.implicitHeight + 6
        implicitHeight: implicitWidth
        radius: implicitWidth / 2
        color: root.pressed ? Qt.darker(root.checkedColor, 1.2) : root.checkedColor

        layer.enabled: root.hovered | root.pressed
        layer.effect: DropShadow {
            transparentBorder: true
            color: root.checkedColor
            samples: 10 /*20*/
        }
    }
}

滑动条样式代码

main_page3.png
GridLayout {
    width: root.width
    rows: 3
    columns: 3

    Repeater {
        id: spinBoxRepeater
        model: ["#727CF5", "#0ACF97", "#F9375E",
                "#FFBC00", "#2B99B9", "#5A6268",
                "#EEF2F7", "#212730", "#3498DB"]

        Slider {
            checkedColor: modelData
            value: Math.random()
        }
    }
}
  • 更多精彩内容请关注公众号Qt君

相关文章

  • Flat风格的Qml滑动条

    基于Qml的Slider控件修改而成。 滑动条代码 滑动条样式代码 更多精彩内容请关注公众号Qt君。

  • Flat风格的Qml进度条

    基于Qml的ProgressBar控件修改而成。 进度条代码 进度条样式代码 更多精彩内容请关注公众号Qt君。

  • Flat风格的Qml滚动选择条

    基于Qml的Tumbler控件修改而成。 滚动选择条代码 滚动选择条样式代码 更多精彩内容请关注公众号Qt君。

  • Flat风格的Qml按钮

    使用Qml的Button控件修改而成。 源码 Button源码 按钮组样式源码 关于更多请关注公众号Qt君。

  • Flat风格的Qml开关按钮

    可以打开或关闭的开关按钮,使用Qml的Switch控件修改而成。 0x00 Switch按钮代码 0x01 Swi...

  • Flat风格的Qml轮选框

    基于Qml的SpinBox控件修改而成。 轮选框代码 轮选框样式代码 更多精彩内容请关注公众号Qt君。

  • Flat风格的Qml范围滑块

    基于Qml的RangeSlider控件修改而成。 范围滑块代码 范围滑块样式代码 更多精彩内容请关注公众号Qt君。

  • Flat风格的Qml输入框

    基于Qml的TextField控件修改而成。 0x00 输入框代码 0x01 输入框样式代码 更多请关注公众号Qt君

  • Flat风格的Qml单选/复选按钮

    使用Qml的RadioButton与CheckBox控件修改而成。 单选按钮 RadioButton代码 Radi...

  • 2018-05-02

    ICON的风格: MBE LINEAR FLAT

网友评论

      本文标题:Flat风格的Qml滑动条

      本文链接:https://www.haomeiwen.com/subject/apghnctx.html