tisdag 2 oktober 2012

Qt quick folderlistmodel

To be able to use folderlistmodel in qml, install it like this:
sudo apt-get install libqt4-declarative-folderlistmodel
and use it like this:
import QtQuick 1.1
import Qt.labs.folderlistmodel 1.0

ListView {
  id:myListView
     width: 200; height: 400

    FolderListModel {
         id: folderModel
         nameFilters: ["*.svg"]
         folder: "./images/"
         showDirs:false
     }

    Component{
      id:fileDelegate
 
      Item{
        width:myListView.width
        height:myListView.height/10
  
        Text { id :imageInfo 
          text: "file name",fileName
          width:parent.width 
          height:imageInfo.text.height 
         }
        Image { source: filePath 
          anchors.top:imageInfo.bottom
          width:parent.width 
          height:parent.height}
      }
    }
     
  model: folderModel
  delegate: fileDelegate
}
Read more here: folderlistmodel


Inga kommentarer: