Results 1 to 5 of 5

Thread: QFileDialog freezes

  1. #1
    Join Date
    Jun 2013
    Posts
    20
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default QFileDialog freezes

    Hey guys!

    I got the fllowing problem, which is new for me. I want the user to enter a file location and file name, that I can use to create a file obviously. I got the following code for this:

    Qt Code:
    1. void SpacecraftDataView::saveToFile(){
    2.  
    3. QString fileName = QFileDialog::getSaveFileName(this, "Save Data", "", "Textdatei (*.txt);;All Files(*)");
    4.  
    5. if(fileName.isEmpty()){
    6. return;
    7. }else{
    8. QTextDocumentWriter writer(fileName);
    9. if(!writer.write(&dataProcessor->getDocument())){
    10. QMessageBox::information(this, tr("Unable to write to file"), "Writing to file was not possible.");
    11. return;
    12. }else{
    13. //! \todo something here
    14. }
    15. }
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 

    Note it does not execute past the getSaveFileName part. This does open a QFileDialog which then freezes in the middle of its execution, see screenshot:



    So what am I doing wrong?

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFileDialog freezes

    have you tried to set a start folder for the dialog?

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,321
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFileDialog freezes

    Try putting "*.*" in your "All Files" filter. It's possible that's what is causing the hangup. If you don't specify a starting directory, it will default to the app's current directory.

  4. #4
    Join Date
    Jun 2013
    Posts
    20
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFileDialog freezes

    I tried both and it was both not helping.

    What did solve the problem was setting the option
    Qt Code:
    1. QFileDialog::DontUseNativeDialog.
    To copy to clipboard, switch view to plain text mode 

    So I suppose there is something interfering with Qts Native Dialog. I suspect it is some kind of Plugin, though I dont know a way how to find that plugin. Any Ideas?

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QFileDialog freezes

    The native dialog is not part of Qt but part of your operating system/window manager. Once Qt opens that dialog what it does as it initialises is not within Qt control.

Similar Threads

  1. Replies: 7
    Last Post: 5th March 2014, 17:36
  2. QNetworkAccessManager->get freezes when called in DLL
    By Sajjmon in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2012, 16:38
  3. Replies: 1
    Last Post: 25th March 2012, 22:15
  4. GUI freezes in loop: Thread does not help?
    By Matty23 in forum Qt Programming
    Replies: 4
    Last Post: 25th November 2010, 21:04
  5. Keyboards freezes
    By giusepped in forum Qt-based Software
    Replies: 0
    Last Post: 28th October 2008, 01:30

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
  •  
Qt is a trademark of The Qt Company.