views:

9

answers:

1

Is there a way of doing this without using a QItemDelegate? I've been having a lot of trouble with it. For example, if I use a Delegate: 1) Won't have a native dialog. 2) I'll have to implement my own image preview, 2) For some reason I can't resize the window cause setGeometry doesn't work, etc etc.

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

OK so the editor->setGeometry method has to go in the overridden 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?

Alberto Toglia