Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileDialog::getOpenFileName - dialog not closing on file select under OS X
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
filedialogos xdialog
9 Posts 5 Posters 4.3k Views
  • 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 Offline
    R Offline
    rwillard
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      Magnum
      wrote on last edited by
      #2

      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
      0
      • M Magnum

        Which version are you using?

        I'm using:

        QMake version 3.0
        Using Qt version 5.4.1

        and It works properly.

        R Offline
        R Offline
        rwillard
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Magnum
          wrote on last edited by
          #4

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

          R 1 Reply Last reply
          0
          • M Magnum

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

            R Offline
            R Offline
            rwillard
            wrote on last edited by
            #5

            @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
            0
            • R Offline
              R Offline
              Rondog
              wrote on last edited by
              #6

              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
              0
              • M Offline
                M Offline
                mcosta
                wrote on last edited by
                #7

                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
                0
                • M mcosta

                  Hi,

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

                  R Offline
                  R Offline
                  rwillard
                  wrote on last edited by
                  #8

                  @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
                  0
                  • M Offline
                    M Offline
                    maximus
                    wrote on last edited by
                    #9

                    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
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved