PDA

View Full Version : QFileDialog:getSaveFilename()Crash when I tried to create Newfolder in Opened dialog



jbcp
5th September 2014, 07:23
Hi All,

When I use the code below

QString name = QFileDialog::getSaveFileName(this, "Save As: ",QDir::currentPath(),"PNG(*.png)"); and in the Pop Up Dialog/Window if I tried to create a NewFolder ,my application is crashing(Windows7,64bit).

I tried below code

QString name = QFileDialog::getSaveFileName(this, "Save As: ",QDir::currentPath(),"PNG(*.png)",0,QFileDialog:: DontUseNativeDialog);Then I can create a NewFolder but the popped Dialog doesn't have Icon.

Setting the Icon like below code doesn't help.

QFileDialog filedlg;
filedlg.setWindowIcon(QIcon(":/new/Icon.ico"));
filedlg.getSaveFileName(this, "Save As: ",QDir::currentPath(),"PNG(*.png)",0,QFileDialog:: DontUseNativeDialog);

Can anyone correct me what I am doing wrong?I want to use native dialog itself, any suggestions on the crashing?

Thanks in Advance.

anda_skoa
5th September 2014, 07:56
getSaveFileName() is static, so your third code is no different than the second one.

The QFileDialog documentation shows how to use an instance of QFileDialog. You create the instance, configure its behavior, then exec() it.

It might be worthwhile though, to try to debug why you are getting a crash when using the native dialog.

Cheers,
_

jbcp
5th September 2014, 11:29
Hi anda_skoa,

Thanks for your prompt reply.

This is what the message on crash

Windows has triggered a breakpoint in app.exe.

This may be due to a corruption of the heap, which indicates a bug in app.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while app.exe has focus.

The output window may have more diagnostic information.

And a cursor pointing to the 3rd line of below code snippet from the file qfiledialog_win.cpp

I am not understanding where I am doing wrong .Please can you help me with this.

Thanks

jbcp
6th September 2014, 07:01
Sorry I forgot to add the code snippet from the file qfiledialog_win.cpp where cursor is pointing after crash

if (idx)
ofn->nFilterIndex = idx + 1;
if (GetSaveFileName(ofn)) {
result = QString::fromWCharArray(ofn->lpstrFile);
selFilIdx = ofn->nFilterIndex;
}

Thank you

anda_skoa
6th September 2014, 17:18
Hmm, strange.

I don't have any experience with Qt on Windows, so maybe someone else can help you further.

Cheers,
_