Results 1 to 3 of 3

Thread: Call QFileDialog when trying to edit cell of QTableView, put file name after return.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Call QFileDialog when trying to edit cell of QTableView, put file name after return.

    Hi, In my QTableView one of my columns refers to a file name, so when editing a cell of this column I would like to call a QFileDialog to make the user choose the file. And I know this can be done with a QItemDelegate.

    So, this is my createEditor attempt:
    Qt Code:
    1. QWidget *createEditor(
    2. QWidget *parent,
    3. const QStyleOptionViewItem &option,
    4. const QModelIndex &index
    5. ) const {
    6. Q_UNUSED(option);
    7. Q_UNUSED(index);
    8.  
    9. QFileDialog* editor = new QFileDialog(parent);
    10. editor->setFilter("*.png");
    11. editor->setDirectory(mResources);
    12.  
    13. return editor;
    14. };
    To copy to clipboard, switch view to plain text mode 

    And actually this does work. But I still wish I could use getOpenFileName to get the native dialog which looks cooler and also shows a preview of the images.

    So is there a better way of doing this that I can use getOpenFileName method, maybe attaching some signals or slots?

    Thanks for any help.
    Last edited by toglia3d; 12th October 2010 at 19:25.

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Replies: 11
    Last Post: 3rd October 2010, 11:22
  3. Replies: 1
    Last Post: 19th March 2010, 13:59
  4. Replies: 8
    Last Post: 23rd October 2009, 15:33
  5. Replies: 7
    Last Post: 3rd July 2008, 08:02

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.