setting default file extension when creating a new file...
-
I don't know what "Haiku" is as an operating system. I can only say that under Ubuntu 22.04 with Qt5 (all I have)
QFileDialog::getSaveFileName(&w, "Caption", QString(), "*.cpp"); // or QFileDialog::getSaveFileName(&w, "Caption", QString(), "*.cpp", nullptr, QFileDialog::DontUseNativeDialog);
These use native dialog/Qt dialog respectively. Both apply the
*.cpp
filter from the outset, and neither has a "show all" filter. -
I don't know what "Haiku" is as an operating system. I can only say that under Ubuntu 22.04 with Qt5 (all I have)
QFileDialog::getSaveFileName(&w, "Caption", QString(), "*.cpp"); // or QFileDialog::getSaveFileName(&w, "Caption", QString(), "*.cpp", nullptr, QFileDialog::DontUseNativeDialog);
These use native dialog/Qt dialog respectively. Both apply the
*.cpp
filter from the outset, and neither has a "show all" filter. -
if (maybeSave()) {
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Empire Config"),"", tr("Empire Config Files (*.emp)"));
if (!fileName.isEmpty())
loadFile(fileName);
}@MarisaG
Yep same as mine. Just try*.emp
in place ofEmpire Config Files (*.emp)
, though it should be same.I think actually you are using your OS' native dialog, and that may behave differently (and I don't know whether you can affect it). Try my one with
QFileDialog::DontUseNativeDialog
and see how that compares/behaves. -
@JonB I have the filter, and if I manually choose it it gets applied, but I would like the filter to be applied by default and the "show all" filter to be optional. I'm using qt5 on Haiku... And using the qt file dialog.
@MarisaG said in setting default file extension when creating a new file...:
I have the filter, and if I manually choose it it gets applied, but I would like the filter to be applied by default and the "show all" filter to be optional.
Try:
QString fileName = QFileDialog::getOpenFileName(0L, "Open Empire Config","", "Empire Config Files (*.emp) ;; All Files (*)");
-
Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...
@MarisaG said in setting default file extension when creating a new file...:
Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...
Could be "Haiku" related behavior.
Have you tried @JonB 's suggestion here:@JonB said in setting default file extension when creating a new file...:
Try my one with QFileDialog::DontUseNativeDialog and see how that compares/behaves.
Maybe Haiku adds "All files" by default or so. Don't know. Usually, on Windows, Linux and even Mac (AFAIK) you don't have "All files", when you set a filter which excludes it.
-
@MarisaG said in setting default file extension when creating a new file...:
Hmm :( Maybe i will have to ask in the haiku forums for people who have experience with qt...
Could be "Haiku" related behavior.
Have you tried @JonB 's suggestion here:@JonB said in setting default file extension when creating a new file...:
Try my one with QFileDialog::DontUseNativeDialog and see how that compares/behaves.
Maybe Haiku adds "All files" by default or so. Don't know. Usually, on Windows, Linux and even Mac (AFAIK) you don't have "All files", when you set a filter which excludes it.
@Pl45m4 I do want it to look like a native app, so i like the way this is working other than the file list. I rearranged my file layout so that it defaults to looking for the config files for empclient under the system config area so this is not as much a issue anymore.
I'm sure i will have more questions LOL.
-
@Pl45m4 I do want it to look like a native app, so i like the way this is working other than the file list. I rearranged my file layout so that it defaults to looking for the config files for empclient under the system config area so this is not as much a issue anymore.
I'm sure i will have more questions LOL.
@MarisaG said in setting default file extension when creating a new file...:
I do want it to look like a native app, so i like the way this is working other than the file list
Yes, understood. But have you tried it? :)
If you try Qt's FileDialog (QFileDialog::DontUseNativeDialog
flag set) and there is only one "All Files" left, then you know for sure that it is Haiku's default file dialog that has its own "All Files" (which Qt has no control over).