Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess Exit Status always 0 or Normal Exit Why ?
Forum Updated to NodeBB v4.3 + New Features

QProcess Exit Status always 0 or Normal Exit Why ?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abhinay
    wrote on last edited by
    #1

    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_OBJECT

    public:
    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved