2010-10-12 92 views
1

有没有这样做,而不使用QItemDelegate?我一直有很多麻烦。例如,如果我使用委托人:当试图编辑QTableView中的单元格时调用QFileDialog

  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; 
    }; 
    

回答

0

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

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

1

实际上,改变窗口小部件几何图形的所有内容都转到updateEditorGeometry函数。重写它以避免尝试原始对话框将对话框放入表格的单元格中。

相关问题