Call QFileDialog when trying to edit cell of QTableView, put file name after return.
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:
Code:
) const {
Q_UNUSED(option);
Q_UNUSED(index);
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.
Re: Call QFileDialog when trying to edit cell of QTableView, put file name after retu
I can't even resize the dialog window. Something weird is happening when I return the editor that's changing the geometry of the QFileDialog.
Code:
) const {
Q_UNUSED(option);
Q_UNUSED(index);
editor->setFilter("*.png");
editor->setDirectory(mResources);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;
return editor; // <--- tiny file dialog;
};
Re: Call QFileDialog when trying to edit cell of QTableView, put file name after retu
OK so the editor->setGeometry method has to go in the override method setEditorData of the QItemDelegate.
Does anyone know of an example code where the setItemDelegate is used to paint the thumbnail preview of the images in the QFileDialog?