Results 1 to 3 of 3

Thread: Having some silly problems in using a QFileDialog ..

  1. #1
    Join Date
    Jun 2010
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

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

    Qt Code:
    1. 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:

    Qt Code:
    1. QString sf = "PNG files (*.png)";
    2. 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:


  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Having some silly problems in using a QFileDialog ..

    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?

  3. #3
    Join Date
    Jun 2010
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: Having some silly problems in using a QFileDialog ..

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



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

Similar Threads

  1. QFileDialog
    By rmagro in forum Qt Programming
    Replies: 8
    Last Post: 17th February 2010, 16:57
  2. Need a help about QFileDialog
    By Achayan in forum Qt Programming
    Replies: 4
    Last Post: 27th August 2009, 09:12
  3. QFileDialog use
    By Doug Broadwell in forum Qt Programming
    Replies: 4
    Last Post: 15th February 2008, 09:24
  4. silly undefined refrence to main
    By quickNitin in forum Newbie
    Replies: 3
    Last Post: 16th November 2006, 09:41
  5. silly array element counter..
    By ct in forum General Programming
    Replies: 4
    Last Post: 3rd March 2006, 15:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.