Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Weird behaviour with QFileDialog::getExistingDirectory



  • Hi, my problem seems to be simple but it is driving me nuts.

    I my main.cpp I can read a second argument that points to the file that will be loaded and this seems to be working perfectly.

    Also that app asks you for a path to export some data and here starts the unexpected behaviour.

    If I load the file with that commandline it opens the folder explorer using the Qt mode instead using the OS (Windows) one.
    Also I can load that file with QFileDialog::getOpenFileName and if I call this before it uses the OS mode, also if I open it using the commandline but I use QFileDialog::getOpenFileName after that it opens the OS mode.

    Notice that after opening that Qt mode dialog the app crashes, I think that something becomes mad internally, but if I open it using commandline, and I launch QFileDialog::getOpenFileName even if I cancel the open (so the previous commandline loaded file is still the loaded one) everything works like a charm.

    Any tip on this? Thank you in advance!!!

    Btw I'm not sure if this is important but QFileDialog::getExistingDirectory is called from inside a QThread.



  • Confirmed: If I call getExistingDirectory out of the thread and send the result as param to the QThread everything works as is expected so it could be a bug on the Qt side.


  • Lifetime Qt Champion

    Hi,

    One base rule: all GUI manipulation must be done in the main thread (well the one that started the QApplication event loop).


Log in to reply