Results 1 to 5 of 5

Thread: QProcess calls finished signal before started process exits

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QProcess calls finished signal before started process exits

    I'm new to QT so I'm sure I'm either misunderstanding something or just doing something wrong.
    The problem is that when I run the code below, it opens up the application and also immediately
    calls the finished() function even though the application is still running. I wouldn't expect it to
    emit the finished signal until after the application has exited?

    What am I missing?

    Here is my test code.

    *****************************************
    mainwindow.h
    ==========
    Qt Code:
    1. private slots:
    2. void procEditFinished(int exitCode, QProcess::ExitStatus exitStatus);
    3.  
    4. private:
    5. QProcess *procEdit;
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    ============
    Qt Code:
    1. void MainWindow::on_btnEdit_clicked()
    2. {
    3. QString app = "/usr/bin/gedit";
    4.  
    5. arg << "file.txt";
    6. procEdit = new QProcess(this);
    7. connect(procEdit, SIGNAL(finished(int, QProcess::ExitStatus)),
    8. this, SLOT(procEditFinished(int, QProcess::ExitStatus)));
    9.  
    10. procEdit->start(app, arg);
    11. }
    12.  
    13. void MainWindow::procEditFinished(int exitCode, QProcess::ExitStatus exitStatus)
    14. {
    15. qDebug("exitCode= %d, exitStatus= %d", exitCode, exitStatus);
    16. procEdit->deleteLater();
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 2nd June 2012 at 01:45. Reason: missing [code] tags

Similar Threads

  1. QProcess finishes but never emits finished signal
    By BettaUseYoNikes in forum Qt Programming
    Replies: 2
    Last Post: 3rd December 2011, 08:01
  2. Qt Creator: The process could not be started!
    By AlphaWolf in forum Qt Programming
    Replies: 5
    Last Post: 24th September 2009, 03:31
  3. Replies: 8
    Last Post: 27th August 2009, 14:51
  4. QProcess object not emitting finished(int) signal
    By Tiansen in forum Qt Programming
    Replies: 13
    Last Post: 14th November 2008, 12:17
  5. Replies: 2
    Last Post: 30th March 2007, 08:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.