Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileDialog::getOpenFileName() returning incorrect file
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::getOpenFileName() returning incorrect file

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toralf
    wrote on last edited by
    #1

    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));
    

    }
    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toralf
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          toralf
          wrote on last edited by
          #4

          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"?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved