Reputation: 377
I need to get the QModelIndex from a filepath and filename in a QFileSystemModel
. I saw there is the index
function which takes a filepath
but I don't know what the column argument should do.
Upvotes: 0
Views: 679
Reputation: 243897
You have to overwrite the index() method of QFileSystemModel so that it can be accessed from QML:
class DisplayFileSystemModel : public QFileSystemModel {
Q_OBJECT
public:
...
Q_INVOKABLE QModelIndex index(const QString &path, int column = 0) const
{
return QFileSystemModel::index(path, column);
}
...
};
And then in QML you use it following form:
your_model.index(your_fullpath)
Upvotes: 1