2010-10-12 95 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函數。重寫它以避免嘗試原始對話框將對話框放入表格的單元格中。

相關問題