Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Runtime error when cancelling QFileDialog
Good pm! I'm new to Qt Creator and can't seem to find a thread in any forum that is helpful for my issue. Whenever I cancel the QFileDialog::getOpenFileNames function, i get a runtime error "Invalid parameter passed to C runtime function." This happens when using both (X) button and cancel button. Error happens when the program runs the function and does not reach checking if QStringList is null/empty...Help would be greatly appreciated
m.sue last edited by
please show the code that you are speaking of.
fileNames = QFileDialog::getOpenFileNames(this, "Select a file to open...","/home","Excel (*.xls)");
m.sue last edited by m.sue
you are still a bit sparse on details.
Does it happen in debug or release mode?
Does it happen even when you run the program outside of QtCreator?
Which Qt version?
Which QtCreator version?
It happens while running the code in Qt Creator. I have not tried creating an executable program so I can't say if it will happen outside Qt Creator.. but isn't that how it goes, if it happens in debug mode it will happen during exe run as well? OS is Windows 7. Qt Creator Version is 5.7.0. This is the error message
VRonin last edited by
Your problem is almost surely not in the code you posted, could you show us what you do next with fileNames?
there's a checking of whether or not the list is empty and the program should inform the user if it was cancelled. but it doesn't even reach the checking. i tried creating a messagebox before the checking just to see if fileNames was populated. it did not reach that part of the code either. From observation, the program crashes when QFileDialog::getOpenFileNames is being cancelled. I just don't know how I'm supposed to handle it. I can't even determine what the return value is because the system crashes first.
if(fileNames.empty())// CHECKS IF NOT EMPTY OR CANCELLED
cancelled.setWindowTitle("Failed File Selection");
cancelled.setText("No file Selected");
m.sue last edited by
I have not tried creating an executable program
I do not understand how QtCreator can execute this code without you having an executable program.
You should try with a clean default project.
And only call QFileDialog::getOpenFileNames(xxx)
If it can crash on that line alone then your windows is not in fully working condition :)