Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt QFileDialog - native dialogs only with static functions?

I'm trying to simply save a file. However, I need a filename entered without a suffix to automatically get a default suffix (which setDefaultSuffix() does).

I'd rather not completely lose the native save dialog just for this. exec() is not overloaded from QDialog, so it totally bypasses the native hook (ignoring the DontUseNativeDialog option even if it's false).

If I disable the file overwrite warning and append the default suffix myself after the function returns, then I'd be re-opening the dialog if the user did not want to overwrite... and that's just ugly.

Is there some signal I can catch and quickly inject the default suffix if it's not there? I'm guessing not, since it's a native dialog.

Is there something I'm doing wrong with the filter? I only have one filter choice. It should use that extension.

This seems pretty lame. Launching the save dialog and simply typing "test" should never result in an extensionless file. "test.", yes. "test" no way. That'll really confuse the users when they hit Load and can't see the file they just saved.

I guess the cross-platform part of Qt is giving me lowest common denominator file dialog functionality?

like image 480
darron Avatar asked Apr 09 '10 16:04

darron


1 Answers

Yes, if you look at the Qt source code it is evident that only the static functions uses native file dialogs. It is not possible to get native dialogs any other way, unfortunately...

like image 143
Mathias Avatar answered Sep 22 '22 13:09

Mathias