Results 1 to 8 of 8

Thread: QFileDialog::setDirectory does not appear to work properly in OpenSuSE 11.3 QT 4.6.3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Unhappy Re: QFileDialog::setDirectory does not appear to work properly in OpenSuSE 11.3 QT 4.

    Just a quick note to add to this thread..

    This morning I installed the latest SDK 4.7, rebuilt the app I have attached
    to my previous post. Verified that it was using the newly installed QT libraries
    and not the version installed via openSuSE.

    Same result, the file dialog still insists on opening in the same dir you start
    the app from instead of where it was set to go to...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QFileDialog::setDirectory does not appear to work properly in OpenSuSE 11.3 QT 4.

    You are trying to mix the static getOpenFileName() convenience function, which expects to get the working directory in its calling parameters, and using the dialog exec() or show() methods.

    Try either the static approach:
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QString fileName = QFileDialog::getOpenFileName(this,
    4. tr("Open File"),
    5. "/tmp",
    6. tr("All Files (*.*)")
    7. );
    8.  
    9. if ( filename.isEmpty() )
    10. return;
    11. }
    To copy to clipboard, switch view to plain text mode 
    or the conventional dialog approach
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QFileDialog dialog;
    4. QString filename;
    5.  
    6. dialog.setDirectory( "/tmp" );
    7. dialog.setFileMode(QFileDialog::ExistingFile);
    8. if (dialog.exec()) {
    9. QStringList filenames = dialog.selectedFiles();
    10. filename = filenames.at(0);
    11. }
    12. else
    13. // dialog rejected
    14. }
    To copy to clipboard, switch view to plain text mode 

    The behaviour is inconsistent if you mix the two it would seem.
    Last edited by ChrisW67; 8th October 2010 at 00:15.

  3. #3
    Join Date
    Oct 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Red face Re: QFileDialog::setDirectory does not appear to work properly in OpenSuSE 11.3 QT 4.

    SOLVED -- Thank you very much -- ChrisW67

    Making the changes as you suggested has solved this issue for us.

    Again thanks for the help and the explanation to the cause of the
    problem. Seems no one here caught that mix of the two separate
    approaches, not to mention throwing us off because it had worked
    in the older versions of QT and KDE.

    Curtis

Similar Threads

  1. Replies: 8
    Last Post: 19th August 2010, 12:18
  2. QGraphicsView::scale does not work properly.
    By metdos in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2010, 08:58
  3. QT's style sheet does not work properly on Mac OS X
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2009, 10:50
  4. QLineF::intersect does not work properly (solved)
    By jano_alex_es in forum Newbie
    Replies: 1
    Last Post: 23rd June 2009, 09:06
  5. Why can't I make dynamic_cast work properly?
    By pir in forum General Programming
    Replies: 13
    Last Post: 18th July 2006, 16:17

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.