Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Mouse wheel is not moving scroll bar
Forum Updated to NodeBB v4.3 + New Features

Mouse wheel is not moving scroll bar

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 272 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by Circuits
    #1

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Circuits
      wrote on last edited by
      #2

      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
            }
          }
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved