QFileDialog::getSaveFileName - would like to disable save button for read only folder
Dear All,
I would like to disable file save dialog's save button if the current selected folder is read only folder, I mean I want read only folder indication the moment user selects folder on file save dialog.
Here is the code, I have written to show file save dialog...
Code:
// Show the SaveAs dialog
pParent,
("Save Session File"),
primarySessionPath,
("Sessions (*.sess)") );
This problem is on Mac OS (El Capitan)
I am using Qt 4.7.3.
Please suggest me a solution, if any one has any idea about it.
Overriding QFileDialog or writing some other custom class is the last option I would like to choose.
Thanks,
Re: QFileDialog::getSaveFileName - would like to disable save button for read only fo
I don't think you can do this with the static QFileDialog::getSaveFileName() method. What you will probably have to do is implement a method that uses QFileDialog::exec() (i.e. just like you would for a normal QDialog-based modal dialog) and connect a slot to the QFileDialog::directoryEntered() signal. In that slot, you can check for read-only status for the directory and set a flag that disallows choosing a file from that directory.
I don't think you can get access to the buttons themselves, because Qt uses the native dialogs on each platform, and of course these are not Qt dialogs, just Qt wrappers around the native dialogs.
Re: QFileDialog::getSaveFileName - would like to disable save button for read only fo
Quote:
Originally Posted by
d_stranz
I don't think you can get access to the buttons themselves, because Qt uses the native dialogs on each platform, and of course these are not Qt dialogs, just Qt wrappers around the native dialogs.
Generally true, but one can force non-native dialogs, i.e. use Qt built-in ones, see QFileDialog::DontUseNativeDialog
Cheers,
_
Re: QFileDialog::getSaveFileName - would like to disable save button for read only fo
Quote:
Generally true, but one can force non-native dialogs
Sure, but can you get access to the dialog buttons if you use a built-in Qt one? And what is the look and feel compared to a native dialog? I suppose if you wanted to manually search out the children and find the buttons you could do that, assuming they were implemented as QPushButton in the first place.
Re: QFileDialog::getSaveFileName - would like to disable save button for read only fo
Right, one would have to look for the buttons manually, but I am pretty sure the dialog would be using QDialogButtonBox so that should be trivial.
Cheers,
_
Re: QFileDialog::getSaveFileName - would like to disable save button for read only fo
@anda_skoa & @d_stranz
Thank you very much for your inputs, I got the possible way from your suggestions and will use them according to my requirement.
Thanks,