[Qt-interest] QFileDialog signals

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Sep 2 16:29:35 CEST 2010


On 2010-09-02 Zeljko Zeljko wrote:

>> ...
>> If it's a native dialog, no signals will be emitted.
> 
> hm, then at least qt docs should be updated in this case.

When thinking about this issue again, let's focus on the following: we create instances of QFileDialog exclusively via the c'tors. The Qt doc http://doc.trolltech.com/4.6/qfiledialog.html#details gives the impression that only the *static* methods (getOpenFileName() etc.) would use the native file dialog (if available). 

Only the QFileDialog::DontUseNativeDialog flag hints a little bit that it is in theory also possible to create native instances in different way: it very mysteriously mentions that "By default, the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT macro.", suggesting that also the c'tor would create a native dialog! But by experience that is not the case, at least not on Windows so far (last checked was with Qt 4.6.2). In any case, the Qt docs nowhere explicitly deny that a native dialog could also be created when using a c'tor.

Anyway, let's assume for now that the expectation would be that only the static methods would create a native dialog - IF the QFileDialog::DontUseNativeDialog is NOT set - and every c'tor would create the "Qt file dialog" (non-native).

So now if I would connect to e.g. filterSelected() to do some funky logic (and I would not explicitly set the DontUseNativeDialog off course, see "expectations") and that would work on Windows, but not on KDE, because all of a sudden I WOULD get a native dialog there, that would be an "undocumented pitfall!", so say at least.

So if this is really the case that on KDE the c'tor asks KDE to show a native dialog, and this instance would indeed not support all the functionality as a non-native Qt dialog (with regards to signals), then that would deserve a word or two in the Qt docs:

- Clarify that on some platforms it IS possible that one might get a native dialog, also via c'tor
- Clarify that if one relies on the signals being emitted one should always explicitly set the DontUseNativeDialog


Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22






More information about the Qt-interest-old mailing list