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. How to send INPUT & receive OUTPUT : Calling Python from C++:

How to send INPUT & receive OUTPUT : Calling Python from C++:

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 652 Views
  • 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.
  • A Offline
    A Offline
    ahsan737
    wrote on 28 Jul 2020, 02:42 last edited by
    #1

    Greetings,

    I am executing the following code to call python script from c++ using QProcess.

        QString path = "C:/pythonCPP";
        QString  command("python");
        QStringList params = QStringList() << "pyemb3.py";
        QProcess *process = new QProcess();
        process->startDetached(command, params, path);
        process->waitForFinished();
        process->close();
    

    My question is how can I provide input parameters to and receive the output of python script being called.

    I've skimmed through different forums/references/portals but couldn't get an understandable answer.

    Looking forward to your kind responses.

    Best Regards,
    Ahsan

    J 1 Reply Last reply 28 Jul 2020, 05:24
    0
    • A ahsan737
      28 Jul 2020, 02:42

      Greetings,

      I am executing the following code to call python script from c++ using QProcess.

          QString path = "C:/pythonCPP";
          QString  command("python");
          QStringList params = QStringList() << "pyemb3.py";
          QProcess *process = new QProcess();
          process->startDetached(command, params, path);
          process->waitForFinished();
          process->close();
      

      My question is how can I provide input parameters to and receive the output of python script being called.

      I've skimmed through different forums/references/portals but couldn't get an understandable answer.

      Looking forward to your kind responses.

      Best Regards,
      Ahsan

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 28 Jul 2020, 05:24 last edited by jsulm
      #2

      @ahsan737 https://doc.qt.io/qt-5/qprocess.html "Communicating via Channels"
      Don't use startDetached() and don't call waitForFinished().

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      1/2

      28 Jul 2020, 02:42

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved