Search code examples
qtqtscript

qtscript engine - make system calls


I use qtscript in an application to provide automation capabilities for various functions within the application.

To allow greater flexibility i need the possibility to execute other tools (commandline commands/applications) from the script and get their output (the application itself is not security relevant - so calling random code may be ok).

Is their a way to do this with the basic qtscript module or some 3rd party class that encapsulate this or do i have to do this on my own?


Solution

  • A process can be spawned via QProcess class. It also provides console I/O capabilities to fetch executed process output (standard and error).

    You will need to have a wrapper class however, since QProcess cannot be exposed directly to script environment (e.g. it defines no public slots accessible to a script).

    See Related discussion on qtcentre forum.