Results 1 to 3 of 3

Thread: QFileDialog::getOpenFileName() clear history

  1. #1
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QFileDialog::getOpenFileName() clear history

    The static function of QFileDialog::getOpenFileName() http://doc.qt.io/qt-4.8/QFileDialog#getOpenFileName defines a dir path for the current working directory. For the usage as:
    Qt Code:
    1. QString filename = QFileDialog::getOpenFileName(0, tr("open file"), dirpath);
    To copy to clipboard, switch view to plain text mode 
    it sets the working directory as expected. However, the next time I open the dialog, the current working directory is set to last path where I picked the file from! In other words, history is being set in QFileDialog. I want to open the file dialog from the working directory I have specified, and not bother with the history. Is there a way I can do it, while keep using the convinience static function?
    I can use QFileDialog as a conventional dialog function and not use the convinience function and overcome the issue, but given that there seems no way I can have native dialogs with QFileDialog, I wish to avoid its usage via the conventional dialog way.

  2. #2
    Join Date
    Jul 2011
    Location
    Moscow, Russia
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFileDialog::getOpenFileName() clear history

    Hi!
    try to use that solution http://www.archivum.info/qt-interest...-(SOLVED).html
    or
    there is a function 'void QFileDialog::setHistory ( const QStringList & paths )', but as I realized, it doesnt work
    or you might create your own FileDialog with blackJack and other staff)
    Best, Denis.

  3. #3
    Join Date
    Jul 2011
    Location
    Moscow, Russia
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFileDialog::getOpenFileName() clear history

    correction:
    the path with QSetting doesnt work
    second one with QFileDialog::setHistory - doesnt work, too (as I said before).
    As did I placed below:
    step1. add public function to QFileDialog (yes, it should edit the Qt source)
    Qt Code:
    1. //qfiledialog.h
    2. void clearCurrentHistoryLocation();
    To copy to clipboard, switch view to plain text mode 
    implementation:
    Qt Code:
    1. //qfiledialog.cpp
    2. void QFileDialog::clearCurrentHistoryLocation()
    3. {
    4. this->setHistory(QStringList());
    5. d->clearCurrentHistoryLocation();
    6. }
    To copy to clipboard, switch view to plain text mode 
    step2. add function to QFileDialogPrivate
    Qt Code:
    1. //qfiledialog_p.h
    2. void clearCurrentHistoryLocation();
    To copy to clipboard, switch view to plain text mode 
    implementation:
    Qt Code:
    1. void clearCurrentHistoryLocation()
    2. {
    3. currentHistory.clear();
    4. currentHistoryLocation=-1;
    5. }
    To copy to clipboard, switch view to plain text mode 
    it works, I garantee that)

Similar Threads

  1. QFileDialog::getOpenFileName in DLL
    By OverTheOCean in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2011, 10:31
  2. Why QFileDialog::getOpenFileName is not centered?
    By ricardo in forum Qt Programming
    Replies: 20
    Last Post: 31st August 2009, 00:08
  3. How to clear history in QWebView
    By jimc1200 in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2009, 17:02
  4. Replies: 2
    Last Post: 10th January 2008, 13:52
  5. Replies: 1
    Last Post: 15th October 2007, 00:10

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