QFileDilaog:: cancel button
Hi all,
I am able to open a fileDialog and get the file name (for example:) before selecting the filename, if I click the cancel button or close the fileDialog the messagebox is displayed which is in the code
But the message box should be displayed after the open button is clicked, right now it is displayed if i click cancel button or close the fileDilaog. anyone can give some suggestions.
I have attached the code
Code:
if (!QFile::exists(f
+func
)) {
fileName
= QFileDialog::getOpenFileName(this,tr
("Open CSV File"),
"", tr
("CSV Files (*.csv)"));
QFile::copy(fileName, f
+func
);
QMessageBox::information(this,tr
("Batgenerator"),tr
("Import table succeed"));
--------> MESSAGE box to be displayed after clicking open
m_buttonimporttable->show();
if((m_listCSVmajCSV->selectedItems().count()==1))
{
m_buttonAddVarToFile->show();
m_buttonMajCSV->show();
m_checkBkMajCSV->show();
}
}
Thanks in Advance!
Re: QFileDilaog:: cancel button
getOpenFileName() returns an empty string when cancel is clicked or the dialog is closed, so check fileName.isEmpty()
Cheers,
_
Re: QFileDilaog:: cancel button
Simply test if fileName is not empty
Code:
if( !fileName.isEmpty() )
{
}