尝试在QTableView中编辑单元格时调用QFileDialog

有没有办法在不使用QItemDelegate的情况下执行此操作?我一直遇到很多麻烦。例如,如果我使用委托: 不会有本机对话框。 我必须实现自己的图像预览, 出于某种原因,我无法调整窗口大小因为setGeometry不起作用等等。
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);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;

return editor; // <--- tiny file dialog;
};
    
已邀请:
在实践中,更改窗口小部件几何的所有内容都将转到updateEditorGeometry函数。覆盖它以避免尝试使用原始对话框将对话框放在表格的单元格中。     
好的,所以editor-> setGeometry方法必须进入QItemDelegate的重写方法setEditorData。 有没有人知道一个示例代码,其中setItemDelegate用于绘制QFileDialog中图像的缩略图预览?     

要回复问题请先登录注册