toglia3d
12th October 2010, 18:44
Hi, In my QTableView one of my columns refers to a file name, so when editing a cell of this column I would like to call a QFileDialog to make the user choose the file. And I know this can be done with a QItemDelegate.
So, this is my createEditor attempt:
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
return editor;
};
And actually this does work. But I still wish I could use getOpenFileName to get the native dialog which looks cooler and also shows a preview of the images.
So is there a better way of doing this that I can use getOpenFileName method, maybe attaching some signals or slots?
Thanks for any help.
So, this is my createEditor attempt:
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
return editor;
};
And actually this does work. But I still wish I could use getOpenFileName to get the native dialog which looks cooler and also shows a preview of the images.
So is there a better way of doing this that I can use getOpenFileName method, maybe attaching some signals or slots?
Thanks for any help.