I am currently working in qml and I am using an array where I store the paths of my images:
property var imageList: [
"Imagenes/Image1.png", "Imagenes/Image2.png", ... "Imagenes/Image10.png"
]
...but now I want to use a FolderListModel
FolderListModel {
id:foldermodel
folder: "file:/home/Documentos/proyectoN/Imagenes/"
}
so that it can recognize any folder in any location and obviously its content (images).
The detail is that I don't know how to access each file in that folder and bring the path of each one to continue saving them in my Array : ( imageList [] ).
Those images are then displayed in an Item dynamically.
I hope you can help me, or if you have any other idea it will be gratefully accepted.
Thanks.
Concatenate the element of your array to a static route, not dynamic, when you send it to call you will be forcing it to go through the entire route.
I am the one who asked the above question and found a solution to it:
Well, I had an array where I stored the paths of my images:
But I wanted to use a FolderListModel so that it would recognize any folder that I assigned, and thus be able to access the files (images) of it and be able to send them to show.
What I did was to implement my FolderListModel correctly as follows:
where I indicate that all the files in that folder will be traversed and the name of each file will be sent through the get method (index, string property) and stored in the source variable , and once the name is brought, it is concatenated the path of the folder plus the name of the file so that they are inserted into my imageList array .
Don't forget that the get( int index, string property) method brings the property that you assign according to the index that corresponds to the file inside your folder, in this case you use: "filename" to bring the name of the file , but it is important to indicate that it is a string , I made it easy and inside the method parameter I put my property but indicating that it is a string: "fileName" otherwise it will mark an error and tell you that there is an uninitialized variable.
At the end you will have an array with the paths of each image according to its folder and you will be able to manipulate it as you do. wish.
Thanks. I hope it serves you.