How to fill QML Combobox with name of files present in a folder
-
Hi everybody,
I'm a beginner in QML development, and I have lot of difficulties to understand how to fill a QML ComboBox using a list of file obtained by searching inside a specified folder.
e.g list all *.wav file present in "./MySound" folderThank you for you help.
Foufy -
Hi everybody,
I'm a beginner in QML development, and I have lot of difficulties to understand how to fill a QML ComboBox using a list of file obtained by searching inside a specified folder.
e.g list all *.wav file present in "./MySound" folderThank you for you help.
FoufyHi @Foufy
you should take a look at the docs here
It seems to cover your specific case perfectly. -
Hi and thank you for your answer,
but how to put the result of the folderlistmodel into the combobox. I not able to do it. I'm a real beginner ;)@Foufy pretty straight forward actually:
import QtQuick 2.9 import QtQuick.Window 2.2 import Qt.labs.folderlistmodel 2.1 import QtQuick.Controls 1.4 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") ComboBox { anchors.centerIn: parent width: 200 height: 50 FolderListModel{ id:folderModel } model:folderModel textRole: 'fileName' } }
But I had to use google once, as ComboBox has no basic delegate like
ListView
,for example, has and my standard approach did not work x).Kudos to @p3c0 from this old thread
-
@Foufy pretty straight forward actually:
import QtQuick 2.9 import QtQuick.Window 2.2 import Qt.labs.folderlistmodel 2.1 import QtQuick.Controls 1.4 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") ComboBox { anchors.centerIn: parent width: 200 height: 50 FolderListModel{ id:folderModel } model:folderModel textRole: 'fileName' } }
But I had to use google once, as ComboBox has no basic delegate like
ListView
,for example, has and my standard approach did not work x).Kudos to @p3c0 from this old thread