Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6928951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:15:21+00:00 2026-05-27T11:15:21+00:00

I have a function wrapper for c and python. This wrapper will receive 2

  • 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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:15:21+00:00Added an answer on May 27, 2026 at 11:15 am

    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());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm stuck with a problem of the python wrapper for OpenCv. I have this
I have this toggleClass function: $(document).ready(function() { $(button#playersize).click(function(){ $(#wrapper).toggleClass(small large); $(.divone).toggleClass(small large); $(.divtwo).toggleClass(small large);
I have a wrapper around a C++ function call which I call from C#
I have function: char *zap(char *ar) { char pie[100] = INSERT INTO test (nazwa,
I know, type checking function arguments is generally frowned upon in Python, but I
OK so I have a C++ function with a header like this: int myfunc(vector<int>
I have a function that is taking an arbitrary set of arguments and then
I am trying to write a python C wrapper for a function (libFunc) whose
I have functions in python that take two inputs, do some manipulations, and return
I have a simple library written in C++ which I'm creating a Python wrapper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.