Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QFileDialog::getOpenFileName - dialog not closing on file select under OS X

    General and Desktop
    filedialog os x dialog
    5
    9
    3663
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rwillard last edited by

      in using the QFileDialog::getOpenFileName dialog to select a file under OS X, when clicking on OK (or double clicking the file) to select the name, the file name is passed correctly and the code continues execution, however the actual dialog remains on the screen and unresponsive. This same code works fine under windows and Linux:

      QString filename = QFileDialog::getOpenFileName(this, "Open Study", settings.value("GeneralSettings/SavePath").toString(), "Study File (*.ssd);;All Files(*)");
      	if(!filename.isEmpty()) {
      		OpenFile(filename);
      	}
      

      Any thoughts as to why this may be happening?

      Rob

      1 Reply Last reply Reply Quote 0
      • M
        Magnum last edited by

        Which version are you using?

        I'm using:

        QMake version 3.0
        Using Qt version 5.4.1

        and It works properly.

        R 1 Reply Last reply Reply Quote 0
        • R
          rwillard @Magnum last edited by

          @Magnum QT 5.4.0 (Clang 6.0 (Apple), 64 bit), QMake version 3.0

          1 Reply Last reply Reply Quote 0
          • M
            Magnum last edited by

            Can't you update your Qt to see if the error is version specific?

            R 1 Reply Last reply Reply Quote 0
            • R
              rwillard @Magnum last edited by

              @Magnum A valid observation... obviously tired by the end of the day yesterday. I have updated everything and am still receiving the same results.

              Of note: the OpenFile function opens a file in an MDISubWindow. I have since noticed that the dialog closes if another system dialog overrides it from the main form.

              1 Reply Last reply Reply Quote 0
              • R
                Rondog last edited by

                I am using Qt 5.4.0 on Yosemite and have not seen this problem. I use 'getOpenFileName()' on lots of projects.

                QMake Version: 3.0
                G++ Version: 6.0 (clang-600-0.57)
                Target: x86_64

                The MDISubWindow doesn't sound right (I assume this means it opens in a child window of the parent and not a typical modal dialog). Maybe some window flags are being inherited from the parent widget?

                1 Reply Last reply Reply Quote 0
                • M
                  mcosta last edited by

                  Hi,

                  is your code executed in eventLoop??
                  Have you called QApplication::exec()?

                  Once your problem is solved don't forget to:

                  • Mark the thread as SOLVED using the Topic Tool menu
                  • Vote up the answer(s) that helped you to solve the issue

                  You can embed images using (http://imgur.com/) or (http://postimage.org/)

                  R 1 Reply Last reply Reply Quote 0
                  • R
                    rwillard @mcosta last edited by

                    @mcosta It is a standard QT application with a (mostly) unaltered main loop:

                    int
                    main(int argc, char *argv[]) {
                    	QApplication a(argc, argv);
                    	QCoreApplication::setOrganizationName("###########");
                    	QCoreApplication::setOrganizationDomain("############");
                    	QCoreApplication::setApplicationName("##########");
                    	QCoreApplication::setApplicationVersion("############");
                    	frmMain w;
                    	w.show();
                    
                    	return a.exec();
                    }
                    1 Reply Last reply Reply Quote 0
                    • M
                      maximus last edited by

                      Can you try to comment the line
                      OpenFile(filename);

                      and use a qDebug there instead, this function could be the problem
                      Thanks


                      Free Indoor Cycling Software - https://maximumtrainer.com

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post