I have a QML class that has a function in it with a QStringList as a parameter. I'm able to access other items in the C++ model from QML just fine.
In my QML:
function recentFiles(recentFilesList)
{
//This writes "0" for some reason, although it should be "3"
console.log(recentFilesList.length)
//Causes error: "Unable to assign [undefined] to QString"
return recentFilesList[0]
}
...
Text {
text: recentFiles(rootObject.myModel.recentFiles)
}
In my source file:
QStringList someModel::recentFiles() const
{
QStringList recentFiles;
recentFiles << "A" << "B" << "C";
return recentFiles;
}
In my header file:
Q_INVOKABLE QStringList recentFiles() const;
Ultimately, I'm trying to get my QStringList to work on a QML ListView object where it will display like this:
- A
- B
- C