Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    ListView duplicating last item on update in Windows

    QML and Qt Quick
    3
    3
    2681
    Loading More Posts
    • 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.
    • X
      xsacha last edited by

      Hey
      I have a ListView with a custom C++ model. It's actually the same model documented here: http://doc.qt.nokia.com/4.7/gettingstartedqml.html

      It's a simple folder/file model. The ListView is listing the files of a certain type (.txt) within a chosen folder.

      The problem comes when a new file is added to the folder. I move the list with my mouse and a new item is added to the list. The new item (at the end of the list), now has the same name as the item before it whereas it should instead have the new filename. On Symbian this does not occur.

      Workaround: If I reset the model using model = logDir.files whenever the directory changes, the correct name appears. Though, I shouldn't have to do this?

      Code:
      @
      Component {
      id: filedelegate
      Item {
      height: 50
      x: 20
      width: parent.width - 40
      Text {
      id: nameText
      text: name.replace(/.txt/g, '')
      // ...
      }
      }
      }

      ListView {
      id: loglist
      width: parent.width; height: parent.height - 80;
      x: 20
      y: 20
      spacing: 10
      delegate: filedelegate
      model: logDir.files
      highlight: Rectangle {
      //...
      }
      }@

      • Sacha
      1 Reply Last reply Reply Quote 0
      • 2
        2beers last edited by

        I had a similar situation, and I thought that the only solution was to update(reset) the model. I never tried on Symbian but if you say it's working there and not on desktop's OS you should fill a bug.

        1 Reply Last reply Reply Quote 0
        • B
          blam last edited by

          It sounds like a bug. Can you report it with a small example at bugreports.qt.nokia.com?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post