Reply
Thread Tools
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#1
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:

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:

Code:
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:



Picture from second code:


Last edited by ahmadka; 2010-07-04 at 17:23.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#2
Well I spent a while working on this in PyQt4 and got strange results.

When selecting the "BMP" option, the filename automatically got ".bmp" added to the end of it. When selecting the PNG or JPG I got nothing. Sometimes random special characters would show up in the drop down list.

In all cases.. the selectedFilter never properly updated, and getSaveFileNameAndFilter() would never return anything in the filter index.

There is definitely an issue here. Reading online I've seen other people have similar issues but everyone else just says "Works fine for me."

Using the DontUseNativeDialog both worked fine, as you witnessed.

Odd.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 341 | Thanked: 57 times | Joined on Nov 2009
#3
I know ... I mean I don't see any point in specifying the the filters in the first code .. its useless, does nothing for me .. I've spent the last 6-7 hours going through the docs for QFileDialog, trying to see if I'm missing anything, but I don't think I am ... oh well, I guess I have to think of something else for now ..
 
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#4
This seems to be a big bug in Qt, so please report it on their bug tracker!
 

The Following 2 Users Say Thank You to Venemo For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 14:00.