Results 1 to 7 of 7

Thread: connect a process for output (QT4)

  1. #1
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy connect a process for output (QT4)

    When connecting a QProcess executable (under Windows) to the readyReadStandardOutput signal, the slot function is never called.

    The executable is running fine, as can be seen thru other outputs.

    The slot function uses the readAllStandardOutput function, is running as a QThread
    instance, but seemingly is not accessed by the QT event signalling system.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect a process for output (QT4)

    Quote Originally Posted by icentenee
    When connecting a QProcess executable (under Windows) to the readyReadStandardOutput signal, the slot function is never called.
    May we see the connect statement?

    Also add "CONFIG += console" to your .pro file, compile your application in debug mode and see whether there are any messages on the console.

    Quote Originally Posted by icentenee
    The slot function uses the readAllStandardOutput function, is running as a QThread instance, but seemingly is not accessed by the QT event signalling system.
    If you are connecting to a slot of object that lives in a different thread than the signal sender, make sure you use a direct connection (with proper synchronization mechanism) or that an event loop is running that thread.

  3. #3
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: connect a process for output (QT4)

    The connect statement is:
    scenario = new QProcess;
    scenario->start("./scen_1.exe");
    connect(scenario, SIGNAL(readyReadStandardOutput()), this, SLOT(run()));

    When putting run() in the same instance, nothing is output to the text widget again.
    I got the cosole output option. No debug messages so far.
    Are the .pro files used with MS VC++ ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect a process for output (QT4)

    Quote Originally Posted by icentenee
    The connect statement is:[...]
    Where did you place that? Does it happen to be in some method of QThread subclass?

    Quote Originally Posted by icentenee
    When putting run() in the same instance, nothing is output to the text widget again.
    Is this run() is QThread::run()?

  5. #5
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: connect a process for output (QT4)

    It's in the Dialog class (from QDialog). Only the Dialog instance is implemented.
    I removed the QThread instance. run() is Dialog::run(), i.e. same instance.


    Dialog:ialog()
    {
    createMenu();
    ........................

    setWindowTitle(tr("Run Scenario"));

    scenario = new QProcess;
    scenario->start("./scen_1.exe");
    connect(scenario, SIGNAL(readyReadStandardOutput()), this, SLOT(run()));
    if (!scenario->waitForStarted())
    bigEditor->append(tr("Scenario start failed."));
    else {
    bigEditor->append(tr("Scenario started"));
    }
    }


    void Dialog::run()
    {
    bigEditor->append(tr("read started"));
    QString result_all = scenario->readAllStandardOutput();
    bigEditor->append(tr(result_all.toAscii().data()));
    }

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connect a process for output (QT4)

    Make sure Dialog::run() is listed in one of the "slots" sections and that you have Q_OBJECT macro within your class definition.

  7. #7
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: connect a process for output (QT4)

    thanks very much, it is working now.

Similar Threads

  1. Check wheter a process is running
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2006, 13:35
  2. Replies: 2
    Last Post: 26th April 2006, 11:43
  3. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 19:06
  4. How to activate another process?
    By gtthang in forum Qt Programming
    Replies: 6
    Last Post: 3rd February 2006, 08:53

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.