[SOLVED] QFileDialog.setFileMode() gives wrong behaviour under Windows
I am creating an instance of QFileDialog (Qt5.0.2.) which I want to use to allow the user to select a directory. After creation but before showing the dialog, I am executing the setFileMode(QFileDialog::Directory) method to specify the desired behaviour. Under Linux this does exactly what I think it should. So far, so good.
When I cross-build (the same project) for Windows under Linux (using the MXE cross tools), the QFileDialog reverts to its default behaviour of only allowing the user to select a file. If the user selects a directory, that directory is opened, not selected. This happens under both Wine and on running the cross-built executable on WinXP.
Further, if I build the project natively on WinXP, I still get the wrong behaviour in QFileDialog.
I have added an assert after executing setFileMode() to check the file mode using the fileMode() method and it appears correct. The title of the QFileDialog instance is "Find Directory" (which I am not setting separately).
Am I missing something obvious or is this a pretty egregious bug?
[quote author="b1gsnak3" date="1366704212"]Try with
This doesn't work properly either! Setting the file dialog to show only directories, I still can see files! And the file type combo box at the bottom still says "Any file (.)". (Works absolutely as documented under Linux though.) So this is the second instance of incorrect behaviour under Windows.
I am beginning to suspect this is a depressingly elementary bug ...in a piece of s/w in its 5th major version. Can anybody else reproduce this problem to confirm its either a bug or there is something awry in what I am doing?
and what when you use the "static method":http://qt-project.org/doc/qt-4.8/qfiledialog.html#getExistingDirectory? Does the problem persist?
Or do you depend on the non-OS-native file dialog?
[quote author="b1gsnak3" date="1366710804"]Maybe add
This cracks the problem! Thanks!
(How do I mark this thread as solved?)
Your welcome. Edit your first post and at the title add [SOLVED]