Results 1 to 3 of 3

Thread: Non-native, customized QFileDialog to have Save button instead of Open?

  1. #1
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Non-native, customized QFileDialog to have Save button instead of Open?

    Hi,

    Is there a way to have QFileDialog show Save button instead of Open if it is customized?
    I know I could use QFileDialog::getSaveFileName, but in this case I don't know how to add QUrls to sidebar, etc.

    Thanks!

    Qt Code:
    1. QList<QUrl> sidebarURLs;
    2. sidebarURLs << QUrl::fromLocalFile(lastPath);
    3. sidebarURLs << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
    4. sidebarURLs << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
    5.  
    6. QFileDialog fileOpenDialog(this);
    7. fileOpenDialog.setWindowTitle(tr("Save chart file"));
    8. fileOpenDialog.setDirectory(lastPath);
    9. fileOpenDialog.setViewMode(QFileDialog::Detail);
    10. fileOpenDialog.setSidebarUrls(sidebarURLs);
    11. fileOpenDialog.setFileMode(QFileDialog::AnyFile);
    12. fileOpenDialog.setOption(QFileDialog::DontUseNativeDialog);
    13. fileOpenDialog.setNameFilter(tr("Chart data (*.chart)"));
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2011
    Posts
    61
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Non-native, customized QFileDialog to have Save button instead of Open?

    Qt Code:
    1. fileOpenDialog.setAcceptMode(QFileDialog::AcceptSave);
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to rsilva for this useful post:

    falconium (10th May 2011)

  4. #3
    Join Date
    May 2010
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Non-native, customized QFileDialog to have Save button instead of Open?

    Thanks! I have also just found it from qfiledialog.cpp source code: 02280 dlg->setAcceptMode(AcceptSave);

Similar Threads

  1. QFileDialog::getSaveFileName Save Button
    By penny in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2011, 08:55
  2. Problem displaying image on a customized button
    By bhavikdhoot in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2010, 10:48
  3. Open customized video file
    By cass in forum Newbie
    Replies: 5
    Last Post: 2nd May 2010, 08:52
  4. Native QFileDialog
    By bgougeon in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2009, 01:33
  5. Native QFileDialog
    By adonel in forum Qt Programming
    Replies: 1
    Last Post: 17th September 2008, 18:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.