0

I'm currently testing a software written for windows under MacOS X.6. And most stuff works already, but Currently I'm stuck with 1 thing: The native SaveFileName Dialog under Mac.

QString fileName = m_sSaveAsDir + "untitled." + m_sFileExtension;
qDebug() << "File Extension:" << m_sFileExtension; //"jpg"
qDebug() << "SaveDir:" << m_sSaveAsDir; //""
qDebug() << "Filename:" << fileName; //Filename: "untitled.jpg"
fileName = QFileDialog::getSaveFileName( 0, tr( "Save As" ), 
           fileName, tr("Images (*.dng *.tif *.jpg)"), 0, 0 );
qDebug() << "Filename:" << fileName; //Filename: "//...../Pictures/untitled.dng"

So obviously the former extension jpg is ignored under MacOs and therefore not displayed nor saved. Which is fine for me. Further the Qt manual says that under MacOS the filter is ignored. Which is correct if I have a look at the folder in the Browser in the SaveDialog (the files are not filtered ). But it seems that the first extension in the filter is used as an extension as long as no extension was entered in the filedialog, which is very annoying. How can I come around this problem? I tried to use the NonNativeSaveDialog by changing the last argument in the getSaveFileName() method to "DontUseNativeDialog", which pretty much works but doesnt look good. Any suggestions?

Greetings Donny

Donny
  • 549
  • 2
  • 10
  • 24

1 Answers1

0

You can construct the dialog yourself using non-static QFileDialog methods. Follow the QFileDialog docs for this, then look to QFileDialog::setDefaultSuffix(), which you can set to an empty string, like this:

dialog.setDefaultSuffix(QString());

Then nothing will be automatically appended to the end of the file. I don't have a Mac handy to test this, but it should work.

Anthony
  • 8,570
  • 3
  • 38
  • 46