QProcess Exit Status always 0 or Normal Exit Why ?
-
Hello,
I am developing an application for windows os which can provide us the corrupt files in a directory. For the same i have used QProcess class to open the file. If File opens correctly then the file is ok but if the file does not open properly, then there should be any coruption in the file.For this i have used QProcess and while i am connecting finished SIGNAL and call a slot with it then every time the exitcode returns 0 or normalexit. But i want if the file does not open properly then it should give us the error in the file.
Code -
@class QMainDialog: public QMainWindow, public Ui::MainWindow
{
Q_OBJECTpublic:
QMainDialog(QWidget* parent = 0);
void connectSignal();private slots:
void RunProcess(int exitCode, QProcess::ExitStatus exitStatus);private:
QProcess m_Proc;};
void QMainDialog::startSearch()
{
for (int i = 0; i < m_AllFileList.size(); ++i)
{
QString StrValue = m_AllFileList.at(i);m_Proc.start("cmd.exe", QStringList() << "/C" << StrValue.toAscii());
m_Proc.waitForFinished();
}
}QMainDialog::QMainDialog(QWidget *parent) : QMainWindow(parent)
{
setupUi(this);
connect(&m_Proc, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(RunProcess(int, QProcess::ExitStatus)));
}void QMainDialog::RunProcess(int exitCode, QProcess::ExitStatus exitStatus)
{
if (((exitCode == 0) && (exitStatus == QProcess::NormalExit)))
{
//The file is ok Not corrupted
}
else if ((exitCode != 0) && (exitStatus == QProcess::CrashExit))
{
//The file is corrupted
}
else
{
//
}
}
@Please help me out. Any help will be appreciated.
Regards
Abhinay
S/w engg