Skip to content
  • 0 Votes
    6 Posts
    2k Views
    A

    @qtLove Oops, ok I should have noticed it was in a Component. You can't link directly to properties in a component since they aren't loaded in time (this reason may not be correct, it's my assumption, I'm new to QML too).

    So the way to do this is to add a property to your root item that the component item inherits, like so:

    TestSlider.qml:

    import QtQuick 2.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Controls 1.4 Slider { id:slider orientation: Qt.Vertical height: parent.height property var myRad : 8 property var myColor: "blue" property Component myHandleComp: Rectangle { radius: slider.myRad width: 20 height: 20 color: slider.myColor } style: SliderStyle { id: ss groove: Rectangle { id: rec implicitWidth:parent.height implicitHeight: 1 color: "gray" } handle: myHandleComp } }

    main.qml:

    import QtQuick 2.4 import QtQuick.Controls 1.4 Rectangle { width: 600 height: 600 color: "green" TestSlider { anchors.centerIn: parent myColor: "red" } }

    That allows me to set the color and radius without using an alias into a non-created component item. Note: I broke it out into it's own property Component during some testing I was doing, you do not need to do this. You can just put it straight into handle: YourItem { }.