Hi
There is an issue with QDirModel that has been puzzling me for quite some time. There is a public function in this class with the following signature:
QModelIndex index(const QString &path, int column = 0) const;
To copy to clipboard, switch view to plain text mode
I have another class that inherits QDirModel:
}
class MyDirModel : public QDirModel {
}
To copy to clipboard, switch view to plain text mode
now when I do something like in this:
MyDirModel model;
MyDirModel model;
QModelIndex index = model.index(QString("/Users/anton"), 0);
To copy to clipboard, switch view to plain text mode
it would give compilation error:
no matching function for call to 'MyDirModel::index(QString, int)'
no matching function for call to 'MyDirModel::index(QString, int)'
To copy to clipboard, switch view to plain text mode
To workaround this I usually do something like this:
MyDirModel *model;
qobject_cast<QDirModel
*>
(model
)->index
(QString('..."), 0);
MyDirModel *model;
qobject_cast<QDirModel *>(model)->index(QString('..."), 0);
To copy to clipboard, switch view to plain text mode
What's the trick here?
I'm on Qt 4.6 under Mac. Not sure if it's reproducible on Windows
Thanks
Anton
Bookmarks