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. [Solved] ListView problem: Rows look weird when flicked
Forum Updated to NodeBB v4.3 + New Features

[Solved] ListView problem: Rows look weird when flicked

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.0k 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.
  • E Offline
    E Offline
    ephe
    wrote on last edited by
    #1

    I have modified the "AbstractItemModel":http://doc.qt.nokia.com/qt5/declarative-modelviews-abstractitemmodel.html example a bit.

    I wanted to add a header row which is "fixed".
    Therefore I've created a "Header" item like this:
    Header.qml
    @
    Item
    {
    height: row.height
    width: 400
    Rectangle
    {
    width: 400
    height: row.height
    color: "green"
    }

        Row
        {
            id: row
            Text { text: "col1"; font.pixelSize: 20; width: 100}
            Text { text: "col2"; font.pixelSize: 20; width: 100 }
            Text { text: "col3"; font.pixelSize: 20; width: 100 }
            Text { text: "col4"; font.pixelSize: 20; width: 100 }
        }
    }
    

    @

    I have modified the main.qml so that it also shows the header:
    @

    Rectangle
    {
    width: 400;
    height: 300

    Header {
    id: header}
    
    ListView {
        width: 400; height: 250
        anchors.topMargin: 50
        anchors.fill: parent
    
        model: myModel
        delegate: PointItem {}
        boundsBehavior: Flickable.StopAtBounds
        snapMode: ListView.NoSnap
    }
    

    }
    @

    When starting the application, everything looks fine:
    !http://dl.dropbox.com/u/2346027/ModelAppStartup.PNG(Model App Startup)!

    When I move the columns, it starts looking weird, the header is covered by the first row:
    !http://dl.dropbox.com/u/2346027/ModelAppMoving1.PNG(Model App Moving 1)!

    !http://dl.dropbox.com/u/2346027/ModelAppMoving2.PNG(Model App Moving 2)!

    When I increase the size of the application window, I can see that the first item is still visible:
    !http://dl.dropbox.com/u/2346027/ModelAppBig.PNG(Model App Big)!

    When I continue moving the columns it seems to work fine again.

    But another problem is, that it snaps to the first row, even though I have set the property snapMode to ListView.NoSnap. Does this only affect the last row?

    The first row is moved to the header (even though the topMargin is 50 pixels):
    !http://dl.dropbox.com/u/2346027/ModelAppMoving3.PNG(Model App Moving 3)!
    And then it gets removed:
    !http://dl.dropbox.com/u/2346027/ModelAppMoving4.PNG(Model App Moving 4)!

    Does anybody know what I'm doing wrong? Or is there a problem in the ListView?
    Thank you!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      add
      clip:true
      for ListView

      --
      Vasiliy

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ephe
        wrote on last edited by
        #3

        Thank you, it is working!

        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