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



  • 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



  • Which version are you using?

    I'm using:

    QMake version 3.0
    Using Qt version 5.4.1

    and It works properly.



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



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



  • @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.



  • 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?



  • Hi,

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



  • @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();
    }


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

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.