2

I have a library with classes and public methods written in C++.

I would like, from inside an interactive program written in C++ and Qt, to send commands to a parser in Python language which in turn converts them to call to methods and functions of my library.

Something similar to what is done in Octave/Matlab, a string is processed by a parser which then executes internally the commands.

Somewhere in my C++ library I have a function

int myFooCPPfunction(int value)
{
    return value*value;
}

then during the execution of my program, I want to start a console and type in Python syntax:

for i in range(0,20):
    print("%d" % myFooCPPfunction(i))

The command I gave then updates the internal state of my program for example.

I think it is a matter of writing Python code that links to C++. It seems to me that things like boost::python already do it...I ask your suggestion on which is the better way to write the bindings.

Second point: how to integrate that thing in an interactive shell launched from a Qt application? Some online projects like QConsole should do something similar, but QConsole appears to be a very outdated project.

Thank you!

1 Answer 1

3

PythonQt was created for exactly this purpose.

Sign up to request clarification or add additional context in comments.

1 Comment

In particular the example PyScriptingConsole does the job I intended, thanks for the suggestion

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.