maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Qt] Having some silly problems in using a QFileDialog .. (https://talk.maemo.org/showthread.php?t=57755)

ahmadka 2010-07-04 17:16

[Qt] Having some silly problems in using a QFileDialog ..
 
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:

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

Picture from second code:

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

fatalsaint 2010-07-04 19:49

Re: [Qt] Having some silly problems in using a QFileDialog ..
 
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.

ahmadka 2010-07-04 19:53

Re: [Qt] Having some silly problems in using a QFileDialog ..
 
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 2010-07-05 00:56

Re: [Qt] Having some silly problems in using a QFileDialog ..
 
This seems to be a big bug in Qt, so please report it on their bug tracker!


All times are GMT. The time now is 10:15.

vBulletin® Version 3.8.8