baluk
25th November 2010, 12:42
Hi,
I am using QFilDialog::getOpenFilename() to get the file name chosen by the user. It is working fine for me. But the issue is when the user chose to press the "Cancel" button instead of "Open". When I press the Cancel button I am closing the dialog with close signal. But program get struck after closing the window. I am confused of writing the logic between "open" and cancel" button. My code is
QString Directoryfinder::getFilename()
{
QFileDialog *dialog;
QString filepath = dialog->getOpenFileName(this, tr("Open File"),"/home",tr("Text files(*.txt)"));
if(filepath.isNull())
connect(dialog,SIGNAL(rejected()),dialog,SLOT(clos e()));
return filepath;
}
Can anyone please guide me with the logic.
Thank You,
baluk
I am using QFilDialog::getOpenFilename() to get the file name chosen by the user. It is working fine for me. But the issue is when the user chose to press the "Cancel" button instead of "Open". When I press the Cancel button I am closing the dialog with close signal. But program get struck after closing the window. I am confused of writing the logic between "open" and cancel" button. My code is
QString Directoryfinder::getFilename()
{
QFileDialog *dialog;
QString filepath = dialog->getOpenFileName(this, tr("Open File"),"/home",tr("Text files(*.txt)"));
if(filepath.isNull())
connect(dialog,SIGNAL(rejected()),dialog,SLOT(clos e()));
return filepath;
}
Can anyone please guide me with the logic.
Thank You,
baluk