0

I have a function wrapper for c and python. This wrapper will receive 2 string arguments and convert these two into a tuple and pass it to python script. fileName and className are the c string arguments. pFunc is the python function name.

PyObject *pArgs, *pValue,*pFunc;
pValue = PyString_FromString(fileName);
PyTuple_SetItem(pArgs, 0, pValue);
pValue = PyString_FromString(className);
PyTuple_SetItem(pArgs, 0, pValue);
pValue = PyObject_CallObject(pFunc, pArgs);

the error was cannot convert QString to const char*

i have tried the PyUnicode_FromString API, but still doesnt work, and gave the same error

the inputs are strings and i just want to make the PyObject_CallObject work, regardless of what type of pValue is (preferably strings too).... how do i do this...

1 Answer 1

2

the error was cannot convert QString to const char*

So your strings fileName and className are QString objects, not C strings (const char*)? You have to convert the data first, for example using QString::toAscii():

pValue = PyString_FromString(fileName.toAscii().data());
Sign up to request clarification or add additional context in comments.

Comments

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.