1

有没有办法在不使用 QItemDelegate 的情况下做到这一点?我一直有很多麻烦。例如,如果我使用委托:

  1. 不会有原生对话框。
  2. 我必须实现自己的图像预览,
  3. 由于某种原因,我无法调整窗口大小,因为 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;
    };
    
4

2 回答 2

1

在实践中,所有改变你的小部件几何形状的东西都转到了 updateEditorGeometry 函数。覆盖它以避免尝试将原始对话框放在表格的单元格中。

于 2011-10-24T20:40:32.130 回答
0

好的,所以 editor->setGeometry 方法必须进入 QItemDelegate 的重写方法 setEditorData。

有谁知道 setItemDelegate 用于绘制 QFileDialog 中图像的缩略图预览的示例代码?

于 2010-10-12T19:51:28.987 回答