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. Sending Data to QProcess
Forum Updated to NodeBB v4.3 + New Features

Sending Data to QProcess

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.4k 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.
  • S Offline
    S Offline
    smartsarath2003
    wrote on last edited by
    #1

    HI,
    I have two sample QT4 GUI applications. With the help of my 1stApp I launch my 2ndApp using Qprocess. I linked the Qprocess readyReadStandardOutput() to my slot on 1stApp, so I can read the whatever data send by my 2ndApp.
    Everytime I move my 2nd App window, I write the new window location to stdout using fprintf(), and I read this in my 1stApp slot as below
    @ QProcess* p = (QProcess*) sender();
    QByteArray outputText = p->readAllStandardOutput();
    qDebug() << "TEST05:RECEIVED"<<outputText; @

    All is well. Effectively I can read the status of my 2ndApp from my 1stApp.

    Now I want to control my 2ndApp from my 1stApp. But I can't receive data in 2ndApp (send from 1stApp stdout).
    I want to use something like below (This may be not correct as my 1stApp is not a Qprocess, so wouldn't emit a readyReadStdout() signal)

    @connect(parent,SIGNAL(readyReadStdout()),this,SLOT(my2ndAppSlot()));@

    Is there a way I can connect my 1stApp stdout to a Qprocess (2nApp), so I can read the parent data?
    Thanks in advance

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      QProcess inherits the write() function from QIODevice, so your "parent" process could use the function to write some data, that the "child" process will get in its standard input stream (stdin). I guess you will need something like a separate thread inside the "child" process, which has an finite loop, waiting for some input, e.g. using fread() on then stdin, and generating the signal, as soon as new input is available.

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      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