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. FolderListModel refresh list problem
Forum Updated to NodeBB v4.3 + New Features

FolderListModel refresh list problem

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
folderlistmodel
1 Posts 1 Posters 643 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.
  • R Offline
    R Offline
    RiteshPanchal
    wrote on 7 Jan 2017, 10:32 last edited by
    #1

    I am using ListView using FolderListModel in Qt 5.2.1 on Ubuntu

    Rectangle {
                id: listRect
                width: rootWindow.width
                height: rootWindow.height
                color: "transparent"
                visible: false
    
                Column {
                    Rectangle {
                        width: listRect.width
                        height: 35
                        color: "transparent"
                        Text {
                            id: imgStr
                            text: qsTr("");
                            color: "white"
                            font.pixelSize: 20
                            anchors.verticalCenter: parent.verticalCenter
                            x: 20
                        }
                    }
    
                    Rectangle {
                        id: iHeader
                        width: listRect.width
                        height: 50
                        color: "blue"
                        Text {
                            id: tep
                            text: qsTr("Image Viewer");
                            color: "white"
                            font.pixelSize: 24
                            font.bold: true
                            anchors.centerIn: iHeader
                        }
                    }
    
                    Rectangle {
                        width: listRect.width
                        height: 20
                        color: "black"
                    }
    
                    Rectangle {
                        width: rootWindow.width
                        height: listRect.height - 105
                        color: "black"
    
                        FolderListModel {
                            id: imageModel
                            folder: "file:///media/ubuntu/exSATA/QtVideoBoxDATA/Images"
                            sortField: "Time"
                            sortReversed: true
                        }
    
                        Component {
                            id: fileDelegate
                            Rectangle {
                                width: imageList.width
                                height: 20
                                color: "transparent"
                                Text {
                                    x: 10
                                    text: fileName
                                    color: "white"
                                    font.pixelSize: 16
                                    anchors.verticalCenter: parent.verticalCenter
                                }
                            }
                        }
    
                        Component {
                            id: imageHighlight
                            Rectangle {
                                width: imageList.width
                                height: 20
                                color: "green"
                            }
                        }
    
                        ListView {
                            id: imageList
                            width: rootWindow.width
                            height: listRect.height - 105
                            spacing: 10
                            currentIndex: currentIndex
    
                            model: imageModel
                            delegate: fileDelegate
                            highlight: imageHighlight
                        }
                    }
                }
            }
    

    My program is adding files to the folder used by FolderListModel. But when i review the ListView after, the last file name in list shows the same as the first file name. But when i try to read property of that file name it shows right name. But the list view shows the wrong name.
    If i restart the application it shows the right list.

    I display list using following at key event.

    listRect.visible = true
    imageList.focus = true
    
    1 Reply Last reply
    0

    1/1

    7 Jan 2017, 10:32

    • Login

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