Mouse wheel is not moving scroll bar
Solved
QML and Qt Quick
-
Hey guys, I have built a custom scroll bar for this
TableView
like so:TableView { id: _sectionDetails anchors.margins: sectionReviewPage.style.padding width: parent.width height: 350 selectionMode: SelectionMode.NoSelection backgroundVisible: false frameVisible: false verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff Binding { target: _sectionDetails.flickableItem property: "contentY" value: (_sectionDetails.flickableItem.contentHeight) * vbar.position - (27 - vbar.position) } ScrollBar { id: vbar width: 20 active: true size: (_sectionDetails.height) / (_sectionDetails.flickableItem.contentItem.height) orientation: Qt.Vertical anchors { top: _sectionDetails.top left: _sectionDetails.right bottom: _sectionDetails.bottom } contentItem: Rectangle { id: contentItem_rect2 color: themeManager.currentTheme.palette.highlightColor width: 10 // This will be overridden by the width of the scrollbar height: 10 // This will be overridden based on the size of the scrollbar radius: 5 opacity: 1 } }
For some reason, using the mouse wheel is not making the scroll bar move. It still movies the
TableView
. I guess I would have thought that binding would be done by default but apparently not. What binding do I need here?EDIT: Perhaps I am just approaching this wrong? The default scroll bar that the view provides works perfectly and is great in every aspect except the way it looks. I just want to change the way it looks s/t it is styled as above. I feel like I shouldn't have to remove it to make that happen but I couldn't figure out an easier way.
-
Problem solved using the
style: TableViewStyle{}
style: TableViewStyle { decrementControl: Rectangle { anchors.fill: parent visible: false } incrementControl: Rectangle { anchors.fill: parent visible: false } scrollBarBackground: Rectangle { implicitWidth: 20 color: sectionReviewPage.style.backgroundColor radius: 5 opacity: 1 } handle: Rectangle { implicitWidth: 20 color: themeManager.currentTheme.palette.highlightColor radius: 5 opacity: 1 } }