title: How to handle interactive CLI programmatically in Qt 5 for Windows
body: <p>I have the following interactive CLI -</p>
  
  <pre><code>c:\TEST&gt; python test.py    
  Running test tool.    
  $help    
     |'exec &lt;testname&gt;' or 'exec !&lt;testnum&gt;'    
     |0 BQ1    
     |1 BS1    
     |2 BA1    
     |3 BP1    
  $exec !2    
     |||TEST BA1_ACTIVE    
  $quit    
  c:\TEST&gt;
  </code></pre>
  
  <p>Does anyone know how to do this in Qt5. I try <code>QProcess</code>, but it does not handle the interactive command line shown above since the <code>exec !2</code> is user defined.</p>
  
  <p>For example, <code>QProcess</code> can handle <code>python test.py</code> as shown in the following, however, how do we handle the command inside the CLI, such as <code>exec !2</code></p>
  
  <pre><code>QProcess *usbProcess;
  usbProcess = new QProcess();
  
  QString s = "python test.py"; 
  // ??? how do we handle interactive commands, 
  // such as 'exec !2' or 'exec !1' and etc ???
  
  usbProcess-&gt;start(s);
  //usbProcess-&gt;waitForReadyRead();
  //usbProcess-&gt;waitForFinished();
  QString text =  usbProcess-&gt;readAll();
  qDebug() &lt;&lt; text;
  </code></pre>
  
  <p>The following is just a sample code and the test.py shall be as it is! I am just trying to find a solution outside the test.py.</p>
  
  <pre><code>"""---beginning test.py---"""
  
  from cmd import Cmd
  
  class MyPrompt(Cmd):
  
  def do_help(self, args):
      if len(args) == 0:
          name = "   |'exec &lt;testname&gt;' or 'exec !&lt;testnum&gt;'\n   |0 BQ1\n   |1 BS1\n   |2 BA1\n   |3 BP1'"
      else:
          name = args
      print ("%s" % name)
  
  def do_exec(self, args):
      if (args == "!0"):
          print ("|||TEST BQ1_ACTIVE")
      elif (args == "!1"):
          print ("|||TEST BS1_ACTIVE")
      elif (args == "!2"):
          print ("|||TEST BA1_ACTIVE")
      elif (args == "!3"):
          print ("|||TEST BP3_ACTIVE")
      else:
          print ("invalid input")
  
  def do_quit(self, args):
      print ("Quitting.")
      raise SystemExit
  
  if __name__ == '__main__':
      prompt = MyPrompt()
      prompt.prompt = '$ '
      prompt.cmdloop('Running test tool.')
  """---end of test.py---"""
  </code></pre>