Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Scrollview wheel problem



  • Hello,
    I have gridview and rectangle in scrollview.
    I can scroll when my mouse on gridview but i cant scroll when my mouse on rectangle.
    How can i fix this problem ?

    NOT
    Scroll i mean this not working on rectangle http://prntscr.com/ont7eb

    Black area is - Scrollview
    Red area is - Gridview
    Green area is - Rectangle
    Grey area is - Scroll
    https://prnt.sc/ooj2rh

    And trying to do something like this
    https://miro.medium.com/max/1000/1*yZugJe-acCtHX7e2r71YKw.gif
    Just i have on left side gridview and right side rectangles

    Codes
    https://pastebin.com/uH9DWq3G



  • Help pls



  • Your example is very complicated. I can't understand what rectangle are you talking about, there are too many rectangles. So, my first question is: why do you use ScrollView with GridView? GridView is already a flickable element and supports scrolling out of box.



  • @intruderexcluder I trying to do scroll on all content. When i going down with scroll i want scroll all page not just gridview. I know gridview also flickable but then rectangles not moving. I updated my thread and added picture can u check please. https://prnt.sc/ooj2rh

    And trying to do something like this https://miro.medium.com/max/1000/1*yZugJe-acCtHX7e2r71YKw.gif
    Just i have on left side gridview and right side rectangles



  • Your code is a mess and I still cannot understand it. I wrote a small example of what you want:

        ScrollView {
            id: sv
            anchors.fill: parent
    
            contentHeight: grid.contentHeight
    
            Item {
                width: parent.width * 0.5
                height: parent.height
    
                GridView {
                    id: grid
                    anchors.fill: parent
    
                    cellWidth:  100
                    cellHeight: 100
    
                    model: 123
    
                    delegate: Item {
                        width: GridView.view.cellWidth
                        height: GridView.view.cellHeight
    
                        Rectangle {
                            anchors {
                                fill: parent
                                margins: 2
                            }
                            color: "plum"
    
                            Text {
                                anchors.centerIn: parent
                                text: "Item %1".arg(model.index)
                            }
                        }
                    }
                }
            }
    
            Rectangle {
                anchors {
                    top: parent.top; topMargin: 10
                    right: parent.right; rightMargin: 10
                }
    
                width: parent.width * 0.4
                height: 200
                color: "#424242"
            }
        }
    

    But keep in mind that it is not good solution. In my case whole grid view stretched to its height. This means that all items will be created at start, which could cause a lot of memory consumption. The best way, probably, is to control scroll of grid view by some mouse wheel event and move contentY of grid view by yourself.



  • @intruderexcluder Worked!! Thank you so much for help!


Log in to reply