Menu

slots with non const arguments and datatype mapping

Help
2015-11-03
2015-11-03
  • Joerg Kreuzberger

    Hi!
    i want to implement a pyhton function in c++, using the available PythonQt wrapper in my C++ Application.

    The functions takes a List (integers) as argument. The list is filled (modified) with integer inside the function by calling append.

    If i now try to implement this in c++ with an decorator object calling the methods, the list is modified int the c++ context, but the slot argument seems not to be "retransfered" to Python, just the results (return value) of the slot seems.
    So the slot behaves like "called-by-value"

    Is this correct or do i make a mistake here?
    The only way i found to change the argument is to pass it as pointer, but then i have to use a custom
    type and cannot use normaly python lists any more

     
  • Florian Link

    Florian Link - 2015-11-03

    Since Python lists/tuples are converted to QList<int>, call by value is the only way to go and there is no automatic way to use call by reference.
    But you can modify the list in C++ and return the modified list as return value of the slot.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.