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. Content going above of my ListView while scrolling

Content going above of my ListView while scrolling

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qt quicklistviewcontents
2 Posts 1 Posters 1.8k 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.
  • S Offline
    S Offline
    Sillimon
    wrote on last edited by Sillimon
    #1

    Hello there !

    I got some troubles with the display in Qt...

    I made a ListView displaying content and after fighting with those delegates/model to understand it, i then realized that the content of my ListView sometimes exceeded above it after scrolling.

    Here is my ListView Code :

    ListView
                {
                    id: listViewCardStructure
    
                    anchors.fill: parent
                    orientation: ListView.Vertical
                    spacing: 20
    
                    model: listModel
                    delegate: component
    
                    Component
                    {
                        id: component
    
    
                        Column
                        {
                            Text
                            {
                                text: section
                                font.pixelSize: 13
                                font.bold: true
    
                                MouseArea
                                {
                                    anchors.fill: parent
                                    acceptedButtons: Qt.LeftButton | Qt.RightButton
    
                                    onPressed:
                                    {
                                        parent.style = Text.Sunken
                                        parent.color = "blue"
                                    }
    
                                    onReleased:
                                    {
                                        parent.style = Text.Normal
                                        parent.color = "black"
                                    }
    
                                    onClicked:
                                    {
                                        //ListView current index
                                        listViewCardStructure.currentIndex = index
                                        readWrite2.Sector = listViewCardStructure.currentIndex
                                        textAreaReadWrite.text = readWrite2.readChip();
                                    }
                                }
                            }
    
                            Text
                            {
                                text: block0; font.pixelSize: 13
                            }
    
                            Text
                            {
                                text: block1; font.pixelSize: 13
                            }
    
                            Text
                            {
                                text: block2; font.pixelSize: 13
                            }
                        }
    
    
                    }
    
                }
    

    I searched few solutions on the web and found out the ScrollView QML type. I tried it and put my ListView as the one and only child :

    ScrollView
            {
                anchors.fill: parent
                anchors.topMargin: 20
                anchors.leftMargin: 5
                
                ListView
                {
                    id: listViewCardStructure
                [...]
                }
            }
    

    It now has a vertical ScrollBar, which is cool ! But it doesn't solve my problems...

    I saw some stuff about flickableItem x and y, viewport, etc... but i can't even use it since they ain't recognized in my .qml

    It might be an import problem but i can't find any informations about it... Do you guys have any ideas ?

    Here are my imports (MyLib 1.0 being a qmlRegisterType) :

    import QtQuick 2.6
    import QtQuick.Window 2.2
    
    import QtQuick.Controls 2.2
    import QtQuick.Controls.Styles 1.2
    import QtQuick.Layouts 1.3
    
    import MyLib 1.0
    

    Thankfull for your help, kisses

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sillimon
      wrote on last edited by Sillimon
      #2

      Found those three properties completely randomly on a completely unrelated topic post...

      Dropping them right here, just in case someone needs it :

      clip: true
      boundsBehavior: Flickable.DragAndOvershootBounds
      snapMode: ListView.SnapToItem
      

      They're doing about everything i need. I think that's a common problem beginners fall into but there is not that much topics about it.

      1 Reply Last reply
      1

      • Login

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