QtQuick.Controls.ScrollBar handle's customization based on mouse state, how?



  • Hello, all.

    Target: make the handle e.g. the contentItem of the QtQuick Controls' ScrollBar look different when being hovered, pressed, enabled and disabled. The guidelines for the ScrollBar's customization mention unexisting ScrollBar's sub-elements such as handle where the latter is actually the Control class' contentItem. Here is an excerpt from the official sample customization code:

    handle: Rectangle {
        id: handle
    
        implicitWidth: 6
        implicitHeight: 6
    
        radius: width / 2
        // ...
    

    There's no such sub-element handle belonging to the ScrollBar's class. Again the handle sub-element is mentioned in the documentation of the QtQuick's so-called "Imagine Style". Looking at the "Element Reference" section about QtQuick's ScrollBar the list of elements again mentions handle and background as well. The latter is made available not by the ScrollBar class but again by its parent - Control's one. As the "Imagine Style"'s documentation states both the background and handle (e.g. contentItem) should have all the mouse states separately. Thing is that I failed catching only those of the scroll bar's handle as stated by the ScrollBar official customization example (see comments):

    handle: Rectangle { // as mentioned there's no "handle" property
        id: handle
    
        // ...
    
        radius: width / 2
        color: control.pressed ? "#28282a" : "#bdbebf"
    
        // ...
    
        states: State {
            name: "active"
            when: control.active // there's no "control" property (attached or not)
            PropertyChanges { target: handle; opacity: 0.75 }
        }
    
        transitions: Transition {
            from: "active"
            SequentialAnimation {
                PauseAnimation { duration: 450 }
                NumberAnimation { target: handle; duration: 200; property: "opacity"; to: 0.0 }
            }
        }
    }
    

    I've customized the handle based on the ScrollBar's mouse status but I want handle's customization based on handle's such such as changing color of the handle only upon hovering the handle not due to hovering over the rest of the scroll bar as well.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.