Alright so I'm trying to use a QFileDialog to save files, but I'm facing some issues .. I will explain in a little detail .. I was initially using this code:
QString fileName
= QFileDialog::getSaveFileName(this, tr
("Save File"),
"/home/user/MyDocs/",tr
("JPG files (*.jpg);;BMP files (*.bmp);;PNG files (*.png)"));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"/home/user/MyDocs/",tr("JPG files (*.jpg);;BMP files (*.bmp);;PNG files (*.png)"));
To copy to clipboard, switch view to plain text mode
The problem with the above code was the I' couldn't detect which format the user wanted to save it .. I only received the prefix part of the filename, not the suffix ..
Then I found out that I can use the following code to get around this problem:
QString fileName
= QFileDialog::getSaveFileName(this, tr
("Save File"),
"/home/user/MyDocs/",tr
("JPG files (*.jpg);;BMP files (*.bmp);;PNG files (*.png)"),
&sf,
QFileDialog::DontUseNativeDialog);
QString sf = "PNG files (*.png)";
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"/home/user/MyDocs/",tr("JPG files (*.jpg);;BMP files (*.bmp);;PNG files (*.png)"),&sf,QFileDialog::DontUseNativeDialog);
To copy to clipboard, switch view to plain text mode
With the above code I could determine which format the user wanted to save the file in ..
Now here comes the problem .. The above code ONLY gives me the format filter the user selected IF I'm using the option QFileDialog:: DontUseNativeDialog, which I am in the above code ... The problem is this leads to a very ugly File Dialog .. the File Dialog I get from the first code is *much* better .. only problem with that is I can't figure out which format filter the user finalized on ..
Is there any way I can get the best of both worlds ?
Picture from first code:
Picture from second code:
Bookmarks