QFileDialog::getOpenFileName() returning incorrect file



  • Hi.

    I've got an issue with a program using QFileDialog::getOpenFileName() to get a file selection from the user. I suspect a Qt bug, but I thought I'd run it through the forum before submitting a report. The problem is simply that the call sometimes seems to return a different file from the one actually selected. This does not always happen, but I can reproduce the behaviour as follows:

    Create a new directory and copy a few files to it.

    Trigger QFileDialog::getOpenFileName() in the application...

    In the file selector, go to the directory created above, then select one of the files - and leave the dialog open for now.

    Add another file to the directory via some other application, a text terminal or whatever.

    Wait for the new file to appear in the file selector. (This should happen automatically after a brief delay.)

    Press Open.

    Like I said, the file name I then get does not match the selection I made. This also happens with the simple test program included below.

    Has anyone else seen anything like this?

    I'm using Qt 4.8.5 under CentOS Linux version 6.

    @#include <QApplication>
    #include <QFileDialog>

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);

    QString fileName=
      QFileDialog::getOpenFileName(NULL, "Open A file", qgetenv("HOME"),
       "All files (*)");
    qDebug("%s...", qPrintable(fileName));
    

    }
    @


  • Moderators

    since this is a very straightforward example it's fine when you create a bugreport for it ;)
    Just paste the description from here and OS into the bugreport.



  • One reason or not doing that without a "reality check" would be that this is not necessarily a Qt bug, since a "system" file selector may be used.



  • I'm now quite convinced that this is an issue with the Gtk file selector - which is picked up Qt when the GUI style is "Desktop" (in my setup.) So I think I'll report the issue elsewhere. Or should I still create a Qt bug "for the record"?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.