Derive a custom model from QStringListModel, and override the data() method. In the handler for DisplayRole, use QFileInfo to retrieve the file name only from the path (using QFileInfo::fileName()) and return that as the QVariant. For all other data roles, call the QStringListModel base class data() method.How can I do it? I would have an help on it.
For your processing where you need the entire path, you can implement a handler for Qt::UserRole in your custom model. For that role, you call the base class data() method with the Qt::DisplayRole role, which will return the entire path string. In your list-handling code, you would call into the model with the UserRole when you need the full path.
Bookmarks