PDA

View Full Version : Having some silly problems in using a QFileDialog ..



ahmadka
4th July 2010, 18:39
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)"));

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 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);

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:

http://i48.tinypic.com/97k1va.png

Picture from second code:

http://i49.tinypic.com/2wqs9kx.png

tbscope
4th July 2010, 21:40
This sounds like a bug in Qt, but I couldn't find a report.

Returning or setting the selected filter should always work (at least according to the documentation)

Which version of Qt are your using? Can you try an updated version?

ahmadka
4th July 2010, 21:44
Yeah I reported this on another forum and they said the same .. oh well, for the time being I've thought of using another strategy to get the same work done, but for that I need to know how to get the following control in Qt (if this is even possible):

Here is a picture of the said control (taken from Xournal on N900):

http://i45.tinypic.com/4j5dzl.png

I was wondering if I can get this exact control somehow using Qt .. Is this control available in Qt ?