Wishing my windows build wasn't so windows like
On Linux when you store settings, they're usually stored in a INI text file. On OSX when you store settings, they're usually stored in a XML text file. Is there any way to make my windows build use one of those methods for manipulating settings instead of the awful registry?
On OSX when you go open up a QFileDialog::getOpenFileName the directory it starts in is set to the last directory you visited. Is there anyway to make my windows build behave like this? Preferably combining that with the text file settings mentioned above.
Re: Wishing my windows build wasn't so windows like
Pass IniFormat to a QSettings constructor variant that takes a format parameter.
As for the other question, the dialog takes a path to its starting directory as an argument. Simply store the last used path in some QString and use it here.
Re: Wishing my windows build wasn't so windows like
Quote:
Originally Posted by
wysota
Pass IniFormat to a QSettings constructor variant that takes a format parameter.
I can't belive I missed that, I guess my look over the QSettings docs was too cursory.
Quote:
Originally Posted by
wysota
As for the other question, the dialog takes a path to its starting directory as an argument. Simply store the last used path in some QString and use it here.
My problem at first is that I wasn't sure how to fetch the last used path because I was caught up in thinking that it was a function. But then I realized it should be constructed on the stack in the same manner as message boxes. I have an idea of how to do it now.
Re: Wishing my windows build wasn't so windows like
OK:
QFileDialog FileDialog(this, tr("Open File"), "C:\\", tr("Starcraft maps (*.scm *.scx *.chk);;All Files (*.*)"));
FileDialog.exec();
QString AString = FileDialog.directory().absolutePath();
Works like a charm. Except for the fact that it's giving me a Qt open file dialog instead of a native windows open file dialog. I see an option for DontUseNativeDialog, but I don't see an option for DoUseNativeDialog.
Re: Wishing my windows build wasn't so windows like
Use the static convenience function QFileDialog::getOpenFileName().
Re: Wishing my windows build wasn't so windows like
And if I use that static convenience function, how the hell do I store the last used path in some QString?
Re: Wishing my windows build wasn't so windows like
You can use QFileInfo to get the path of the selected file.
Code:
QString path
= <read from settings>
if (!file.isNull())
{
<store path setting>
}
Re: Wishing my windows build wasn't so windows like
Interesting, but is there a way to store the last visited directory even if the user presses the cancel button?
Re: Wishing my windows build wasn't so windows like
Quote:
Originally Posted by
scwizard
Interesting, but is there a way to store the last visited directory even if the user presses the cancel button?
No, unfortunately there is no way for that when using the static method.
Re: Wishing my windows build wasn't so windows like
Is there any way to to store the last visited directory even if the user presses the cancel button AND use the native dialog?
Re: Wishing my windows build wasn't so windows like
Quote:
Originally Posted by
scwizard
Is there any way to to store the last visited directory even if the user presses the cancel button AND use the native dialog?
I'm afraid the static methods are the only ones for using native dialogs. So I'd say no..