Use python module in qt console application



  • Hi
    I was looking for a cross-platform process utility module in qt but didn't find anything useful. After a bit of research I came across a python module called psutil located at psutil
    Now my question is if its possible to use this module inside my qt application and get back the results from this python module.

    Most of my code is in c++ so i just need to get those values from python and feed them into my functions. One important issue is the dependency of the application on python which means user needs to install python before the qt application can be run... I want to totally avoid the idea of forcing the user to install python as prerequisite.

    Comments are welcome.



  • @iNdicat0r

    It's possible if you embed Python into your Qt C++ code. See https://docs.python.org/2/extending/embedding.html for example. Then if you want to call your own C/C++ functions from within Python you can use SWIG to do this.



  • @KeithS

    Ok so user should have python preinstalled in order to run my qt c++ application? I want to avoid this..



  • @iNdicat0r

    In theory not if your app is built with the python lib and shipped with the dll/shared lib. Of course if any python code requires other python modules or libs then you might need to ship these too and set up your PYTHONPATH env var appropriately.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.