<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QML Scrollview does not work.]]></title><description><![CDATA[<p dir="auto">I need to create a long form using QML. The form will not fit inside the window, so I need for it to be scrollable. However I can't get the scroll view to work. Here is a minimum working example of my problem:</p>
<pre><code>import QtQuick.Window 2.2
import QtQuick 2.9
import QtQuick.Controls 2.3

Window {
    visible: true
    width: 1280
    height: 720
    title: qsTr("Hello World")

    Rectangle{
        anchors.centerIn: parent
        width: parent.width*0.8;
        height: parent.height*0.7;

        ScrollView {
            anchors.fill: parent
            clip: true
            contentHeight: parent.height

            Rectangle{
                id: rect1
                width: parent.width
                height: 200
                color: "#ffff00"
                anchors.horizontalCenter: parent.horizontalCenter
            }

            Rectangle{
                id: rect2
                width: parent.width
                height: 500
                color: "#ff00ff"
                anchors.top: rect1.bottom
                anchors.horizontalCenter: parent.horizontalCenter
            }


            Rectangle{
                id: rect3
                width: parent.width
                height: 500
                color: "#00ffff"
                anchors.top: rect2.bottom
                anchors.horizontalCenter: parent.horizontalCenter
            }

        }

    }


}
</code></pre>
<p dir="auto">As I understand it, this should allow me to scroll in order to see the 3 rectangles. However I only the see the first one and the upper half of the second one and I can't scroll.</p>
<p dir="auto">Any help would be greatly appriciated</p>
<p dir="auto">In case it matter I have tried it with both Qt 5.10 and 5.12 with different compilers and the effect is the same. It seems to be that I'm using it wrong.</p>
]]></description><link>https://forum.qt.io/topic/106756/qml-scrollview-does-not-work</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 10:21:36 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/106756.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Sep 2019 22:02:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QML Scrollview does not work. on Wed, 11 Sep 2019 19:28:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/shrinidhi-upadhyaya">@<bdi>shrinidhi-upadhyaya</bdi></a>  Thank you!! Setting the contet height did the trick!!!</p>
]]></description><link>https://forum.qt.io/post/550663</link><guid isPermaLink="true">https://forum.qt.io/post/550663</guid><dc:creator><![CDATA[aarelovich]]></dc:creator><pubDate>Wed, 11 Sep 2019 19:28:41 GMT</pubDate></item><item><title><![CDATA[Reply to QML Scrollview does not work. on Wed, 11 Sep 2019 14:11:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aarelovich">@<bdi>aarelovich</bdi></a> said in <a href="/post/550427">QML Scrollview does not work.</a>:</p>
<blockquote>
<p dir="auto">I'm not sure what the code was supposed to do, but no I does not work. I still can't get anything to scroll</p>
</blockquote>
<p dir="auto">Sorry, that should have been a textarea not a textedit.  Newer versions of textedit wont scroll.  This works though:</p>
<pre><code>import QtQuick 2.12
import QtQuick.Controls 2.12

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Scroll")

    menuBar: MenuBar {
        delegate: MenuBarItem {
            id: menuBarItem

            contentItem: Text {
                text: menuBarItem.text
                font: menuBarItem.font
                opacity: enabled ? 1.0 : 0.3
                color: menuBarItem.highlighted ? "#ffffff" : "#21be2b"
                horizontalAlignment: Text.AlignLeft
                verticalAlignment: Text.AlignVCenter
                elide: Text.ElideRight
            }

            background: Rectangle {
                implicitWidth: 30
                implicitHeight: 15
                opacity: enabled ? 1 : 0.3
                color: menuBarItem.highlighted ? "#21be2b" : "transparent"
            }
        }

        background: Rectangle {
            implicitWidth: 30
            implicitHeight: 15
            color: "#f0f0f0"

            Rectangle {
                color: "#21be2b"
                width: parent.width
                height: 1
                anchors.bottom: parent.bottom
            }
        }

        Menu {
            title: "File"

            MenuItem {
                text: "Test"
            }
        }
    }

    ScrollView {
        anchors.fill: parent

        ScrollBar.vertical: ScrollBar {
            id: verticalBar
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            anchors.right: parent.right
            hoverEnabled: true
            active: hovered || pressed

            property bool showIt: hovered || pressed

            background: Rectangle {
                implicitWidth: 25
                implicitHeight: 40
                radius: 5
                color: verticalBar.showIt ? "grey" : "transparent"
            }

            contentItem: Item {
                implicitWidth: 25
                implicitHeight: 40
                Rectangle {
                    anchors.fill: parent
                    anchors.topMargin: 6
                    anchors.leftMargin: 4
                    anchors.rightMargin: 4
                    anchors.bottomMargin: 6
                    radius: 10
                    color: verticalBar.showIt ? "#424246" : "transparent"
                }
            }
        }

        ListView {
            width: parent.width
            model: 40
            delegate: ItemDelegate {
                text: "Item " + (index + 1)
                width: parent.width
            }
        }
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/550601</link><guid isPermaLink="true">https://forum.qt.io/post/550601</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Wed, 11 Sep 2019 14:11:39 GMT</pubDate></item><item><title><![CDATA[Reply to QML Scrollview does not work. on Wed, 11 Sep 2019 05:48:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/aarelovich">@<bdi>aarelovich</bdi></a> , just change your <strong>contentHeight</strong>, you have given the contentHeight as parent.height which is wrong, contentHeight should be the height of your content.<br />
So now the contentHeight is <strong>1200</strong> that is <strong>(rect1.height + rect2.height + rect3.height)</strong></p>
<p dir="auto"><strong>Sample code:-</strong></p>
<pre><code>ScrollView {
          anchors.fill: parent
          clip: true
          contentHeight: 1200
          [..]
          [..]
}
</code></pre>
<p dir="auto">Just have a look into the <strong>flickable</strong> documentation[<a href="https://doc.qt.io/qt-5/qml-qtquick-flickable.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qml-qtquick-flickable.html</a>]</p>
]]></description><link>https://forum.qt.io/post/550476</link><guid isPermaLink="true">https://forum.qt.io/post/550476</guid><dc:creator><![CDATA[Shrinidhi Upadhyaya]]></dc:creator><pubDate>Wed, 11 Sep 2019 05:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to QML Scrollview does not work. on Tue, 10 Sep 2019 23:37:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fcarney">@<bdi>fcarney</bdi></a> said in <a href="/post/550422">QML Scrollview does not work.</a>:</p>
<blockquote>
<p dir="auto">ScrollView {<br />
anchors.fill: parent</p>
<pre><code>    ScrollBar.vertical: ScrollBar {
        id: verticalBar
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        hoverEnabled: true
        active: hovered || pressed

        property bool showIt: hovered || pressed

        background: Rectangle {
            implicitWidth: 25
            implicitHeight: 40
            radius: 5
            color: verticalBar.showIt ? "grey" : "transparent"
        }

        contentItem: Item {
            implicitWidth: 25
            implicitHeight: 40
            Rectangle {
                anchors.fill: parent
                anchors.topMargin: 6
                anchors.leftMargin: 4
                anchors.rightMargin: 4
                anchors.bottomMargin: 6
                radius: 10
                color: verticalBar.showIt ? "#424246" : "transparent"
            }
        }
    }
</code></pre>
<p dir="auto">//        ListView {<br />
//            width: parent.width<br />
//            model: 40<br />
//            delegate: ItemDelegate {<br />
//                text: "Item " + (index + 1)<br />
//                width: parent.width<br />
//            }<br />
//        }</p>
<pre><code>    TextEdit{
        id: webview
        //width: parent.width

        //anchors.fill: parent // breaks scrolling
        //textFormat: Text.RichText
        textFormat: Text.PlainText
        //readOnly: true
        focus: true
        selectByMouse: true
        textMargin: 20
        text: "gggggggg\n\n\n\n\n\n\n\n\n\n\ngggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"
    }
}
</code></pre>
</blockquote>
<p dir="auto">I'm not sure what the code was supposed to do, but no I does not work. I still can't get anything to scroll</p>
]]></description><link>https://forum.qt.io/post/550427</link><guid isPermaLink="true">https://forum.qt.io/post/550427</guid><dc:creator><![CDATA[aarelovich]]></dc:creator><pubDate>Tue, 10 Sep 2019 23:37:23 GMT</pubDate></item><item><title><![CDATA[Reply to QML Scrollview does not work. on Tue, 10 Sep 2019 22:23:54 GMT]]></title><description><![CDATA[<p dir="auto">This is from my junk pile, does this work:</p>
<pre><code>ScrollView {
        anchors.fill: parent

        ScrollBar.vertical: ScrollBar {
            id: verticalBar
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            anchors.right: parent.right
            hoverEnabled: true
            active: hovered || pressed

            property bool showIt: hovered || pressed

            background: Rectangle {
                implicitWidth: 25
                implicitHeight: 40
                radius: 5
                color: verticalBar.showIt ? "grey" : "transparent"
            }

            contentItem: Item {
                implicitWidth: 25
                implicitHeight: 40
                Rectangle {
                    anchors.fill: parent
                    anchors.topMargin: 6
                    anchors.leftMargin: 4
                    anchors.rightMargin: 4
                    anchors.bottomMargin: 6
                    radius: 10
                    color: verticalBar.showIt ? "#424246" : "transparent"
                }
            }
        }

//        ListView {
//            width: parent.width
//            model: 40
//            delegate: ItemDelegate {
//                text: "Item " + (index + 1)
//                width: parent.width
//            }
//        }

        TextEdit{
            id: webview
            //width: parent.width

            //anchors.fill: parent // breaks scrolling
            //textFormat: Text.RichText
            textFormat: Text.PlainText
            //readOnly: true
            focus: true
            selectByMouse: true
            textMargin: 20
            text: "gggggggg\n\n\n\n\n\n\n\n\n\n\ngggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"
        }
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/550422</link><guid isPermaLink="true">https://forum.qt.io/post/550422</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Tue, 10 Sep 2019 22:23:54 GMT</pubDate></item></channel></rss>