Results 1 to 8 of 8

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

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

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

    When we use this same code snippet in openSuSE 10.3 which is
    running QT 4.5.2 the setDirectory works OK and the dialog opens
    listing the expected contents...

    "NOTE: the path does not seem to matter"

    QFileDialog dialog;
    QString filename;
    QString path = ConvertPath("ScenarioDir");

    dialog.setDirectory( "/tmp/" );

    QDir rdir = dialog.directory();
    NOTE: rdir is correct here in all cases..

    filename = dialog.getOpenFileName();

    if ( filename.toStdString().empty() )
    return;

    However when running OpenSuSE 11.3 which is running QT 4.6.3 it appears
    the dialog opens up using the path of where the QT binary program we are running
    is executed from....

    Are we missing something here...

    Thanks,

    Curtis
    crubel@compro.net

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,690
    Thanks
    13
    Thanked 1,599 Times in 1,527 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.

    I cannot reproduce this in C++. The dialog opens where the directory was set. If the directory does not exist it defaults to the root directory. Post a small, self-contained example that breaks this way.

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

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

    Quote Originally Posted by ChrisW67 View Post
    I cannot reproduce this in C++. The dialog opens where the directory was set. If the directory does not exist it defaults to the root directory. Post a small, self-contained example that breaks this way.
    I beginning to wonder if this has to do with the implementation of OpenSuSE 11.3's KDE ...that is somehow overriding the directory setting somehow.

    However, I will be out of the office all morning tomorrow. As soon as I get back in to the office I will create one and post it for you.

    Thanks for the quick response..
    Last edited by Lykurg; 6th October 2010 at 08:22. Reason: (nothing changed...)

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

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

    Also you can try to install the official sdk alongside the SuSE ones and see if the error arise there too.

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

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

    If I did all of this correctly there is a small gui app attached to this post that
    exhibits the error under openSuSE 11.3 and not under openSuSE 10.3

    I am also in the process of adding in a vanilla Qt SDK and attempting the
    same test on that. I will post the results as soon as I have them.

    Thanks.....
    Attached Files Attached Files

  6. #6
    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...

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,690
    Thanks
    13
    Thanked 1,599 Times in 1,527 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 01:15.

  8. #8
    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, 13:18
  2. QGraphicsView::scale does not work properly.
    By metdos in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2010, 09: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, 11:50
  4. QLineF::intersect does not work properly (solved)
    By jano_alex_es in forum Newbie
    Replies: 1
    Last Post: 23rd June 2009, 10:06
  5. Why can't I make dynamic_cast work properly?
    By pir in forum General Programming
    Replies: 13
    Last Post: 18th July 2006, 17: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.