Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ScrollBar not working in scrollview.

ScrollBar not working in scrollview.

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 141 Views 1 Watching
  • 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.
  • F Offline
    F Offline
    Fakhr
    wrote on last edited by
    #1

    I'm new to qml and most of my code consists of examples from official documentation and online examples. I've created a scrollview in which there is a rectangle with column and in the column there are multiple buttons. I tried inplementing a scrollbar because the content will be bigger than the container , but the scrollbar does not work any help would be appreciated.
    My code is as follow:

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.15
    import QtGraphicalEffects 1.15
    
    Window {
    width: 740
    height: 580
    visible: true
    color: "#00000000"
    title: qsTr("Hello World")
    
    Rectangle {
        id: rectangle
        color: "#40405f"
        anchors.fill: parent
    
        Button {
            id: button
            text: qsTr("Menu")
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            anchors.leftMargin: 10
            anchors.bottomMargin: 466
            anchors.topMargin: 74
            onClicked: animationMenu.running = true
        }
    
        ScrollView {
            id: scrollView
            width: 0
            anchors.left: button.right
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            anchors.leftMargin: 10
            anchors.bottomMargin: 10
            anchors.topMargin: 10
            clip: true
    
            Rectangle {
                id: rectangle1
                color: "#00000000"
                border.color: "#00000000"
                border.width: 0
                anchors.fill: parent
    
                PropertyAnimation {
                    id: animationMenu
                    target: scrollView
                    property: "width"
                    to: if(scrollView.width == 0) return 240; else return 0
                    duration: 800
                    easing.type: Easing.InOutQuint
                }
    
                Column {
                    id: columnMenu
                    width: 0
                    anchors.fill: parent
                    spacing: 10
    
                    Button {
                        id: button1
                        text: qsTr("Button")
                    }
    
                    Button {
                        id: button2
                        text: qsTr("Button")
                    }
    
                    Button {
                        id: button3
                        text: qsTr("Button")
                    }
    
                    Button {
                        id: button4
                        text: qsTr("Button")
                    }
                }
            }
    
            ScrollBar {
                id: vbar
                hoverEnabled: true
                orientation: Qt.Vertical
                size: scrollView.height / rectangle1.height
                anchors.top: parent.top
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                wheelEnabled: true
                pressed: true
                active: true
            }
        }
    }
    }
    
    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