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 standard Input file question
Forum Updated to NodeBB v4.3 + New Features

QProcess standard Input file question

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    Hi ,
    I just saw that one can redirect the output of a program started form a QProcess through the
    @
    readyReadStandardOutput()
    @

    signal ,I also saw that QProcess has
    @
    void setStandardErrorFile ( const QString & fileName, OpenMode mode = Truncate )
    void setStandardInputFile ( const QString & fileName )
    void setStandardOutputFile ( const QString & fileName, OpenMode mode = Truncate )
    @

    methods.

    Is it possible to send a command to a process started with QProcess through the standardInputFile?For example if I wanted to set a Ctrl +C command to a process to terminate it .Is it possible to do that?If so how .What is the intended use of the file set with
    @
    void setStandardInputFile ( const QString & fileName )
    @

    Thank you for your time.

    Why join the navy if you can be a pirate?-Steve Jobs

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      QProcess is an QIODevice implementation so you can send any input to the process by calling write().
      When you use setStandardInputFile you're redirecting that stream to a file i.e. you can't write() to it anymore and the process you run will read input only from that file.
      One use case I can think of is when you have some process with interactive configuration eg. it asks you for login, password and some other stuff and you're suppose to type it in. You can jam the answers in a file and feed that to the process via this mechanism. I don't think that's terribly useful because apps have usually switches for that sort of thing but nevertheless I can imagine some cases this comes handy. If you use windows command prompt this is the same as passing a file name with "< character":http://technet.microsoft.com/en-us/library/bb490982.aspx to the command.

      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