David García Garzón | 27 Aug 21:12 2012
X-Face

Obtaining QObject from PySide based PyObject (complete)

Sorry for the previous unfinished message. Here goes the final one.

I am porting a CPython library (boost based indeed) from PyQt to PySide.
I had a function in the library that received a Sip wrapped widget 
as a PyObject and I used the very ugly SIP api to recover a pointer to the 
actual C++ QObject. 

Does anyone know how recover the C++ QObject from the PyObject in PySide?

Thanks.
David.

PS: If someone is curious the current sip unwrapper, based on some snippets i 
found, is in here:
	http://clam-project.org/clam/trunk/ipyclam/sipunwrap.cxx
And the function  which uses it is bindUi in
	http://clam-project.org/clam/trunk/ipyclam/Clam_NetworkProxy.cxx
Hugo Parente Lima | 27 Aug 21:23 2012

Re: Obtaining QObject from PySide based PyObject (complete)

On Monday, August 27, 2012 09:12:27 PM David García Garzón wrote:
> Sorry for the previous unfinished message. Here goes the final one.
> 
> I am porting a CPython library (boost based indeed) from PyQt to PySide.
> I had a function in the library that received a Sip wrapped widget
> as a PyObject and I used the very ugly SIP api to recover a pointer to the
> actual C++ QObject.
> 
> Does anyone know how recover the C++ QObject from the PyObject in PySide?

You can use:
Shiboken::Object::cppPointer(...), it's on libshiboken basewrapper.h

It receives two parameters, a SbkObject* and a PyTypeObject*, the SbkObject* 
will be your PyObject*, just cast it and make sure it always will be a Python 
object representing a C++ object bound using Shiboken, the PyTypeObject* must 
be the PyTypeObject* for QObject, you can get it using:

Shiboken::TypeResolver::get("QObject*")->pythonType();

TypeResolver class is located on libshiboken typeresolver.h header.

Hope this would help you.

> Thanks.
> David.
> 
> PS: If someone is curious the current sip unwrapper, based on some snippets
> i found, is in here:
> 	http://clam-project.org/clam/trunk/ipyclam/sipunwrap.cxx
(Continue reading)

David García Garzón | 28 Aug 14:48 2012
X-Face

Re: Obtaining QObject from PySide based PyObject (complete)

On Monday 27 August 2012 16:23:03 Hugo Parente Lima wrote:
> On Monday, August 27, 2012 09:12:27 PM David García Garzón wrote:
> > Sorry for the previous unfinished message. Here goes the final one.
> > 
> > I am porting a CPython library (boost based indeed) from PyQt to PySide.
> > I had a function in the library that received a Sip wrapped widget
> > as a PyObject and I used the very ugly SIP api to recover a pointer to the
> > actual C++ QObject.
> > 
> > Does anyone know how recover the C++ QObject from the PyObject in PySide?
> 
> You can use:
> Shiboken::Object::cppPointer(...), it's on libshiboken basewrapper.h
> 
> It receives two parameters, a SbkObject* and a PyTypeObject*, the SbkObject*
> will be your PyObject*, just cast it and make sure it always will be a
> Python object representing a C++ object bound using Shiboken, the
> PyTypeObject* must be the PyTypeObject* for QObject, you can get it using:
> 
> Shiboken::TypeResolver::get("QObject*")->pythonType();
> 
> TypeResolver class is located on libshiboken typeresolver.h header.
> 
> Hope this would help you.
> 

Yes, thanks, this seems to be just what i needed. You even provided answer to 
what i wanted to ask next, how to identify pyside objects. No time to try it 
just now but i am eager to try it to see if it works. Thanks a lot.
David
(Continue reading)

Hugo Parente Lima | 28 Aug 16:25 2012

Re: Obtaining QObject from PySide based PyObject (complete)

On Tuesday, August 28, 2012 02:48:32 PM David García Garzón wrote:
> On Monday 27 August 2012 16:23:03 Hugo Parente Lima wrote:
> > On Monday, August 27, 2012 09:12:27 PM David García Garzón wrote:
> > > Sorry for the previous unfinished message. Here goes the final one.
> > > 
> > > I am porting a CPython library (boost based indeed) from PyQt to PySide.
> > > I had a function in the library that received a Sip wrapped widget
> > > as a PyObject and I used the very ugly SIP api to recover a pointer to
> > > the
> > > actual C++ QObject.
> > > 
> > > Does anyone know how recover the C++ QObject from the PyObject in
> > > PySide?
> > 
> > You can use:
> > Shiboken::Object::cppPointer(...), it's on libshiboken basewrapper.h
> > 
> > It receives two parameters, a SbkObject* and a PyTypeObject*, the
> > SbkObject* will be your PyObject*, just cast it and make sure it always
> > will be a Python object representing a C++ object bound using Shiboken,
> > the
> > PyTypeObject* must be the PyTypeObject* for QObject, you can get it using:
> > 
> > Shiboken::TypeResolver::get("QObject*")->pythonType();
> > 
> > TypeResolver class is located on libshiboken typeresolver.h header.
> > 
> > Hope this would help you.
> 
> Yes, thanks, this seems to be just what i needed. You even provided answer
(Continue reading)

David García Garzón | 29 Aug 23:48 2012

Re: Obtaining QObject from PySide based PyObject (complete)

On 28/08/12 16:25, Hugo Parente Lima wrote:
> On Tuesday, August 28, 2012 02:48:32 PM David García Garzón wrote:
>> On Monday 27 August 2012 16:23:03 Hugo Parente Lima wrote:
>>> On Monday, August 27, 2012 09:12:27 PM David García Garzón wrote:
>>>> Sorry for the previous unfinished message. Here goes the final one.
>>>>
>>>> I am porting a CPython library (boost based indeed) from PyQt to PySide.
>>>> I had a function in the library that received a Sip wrapped widget
>>>> as a PyObject and I used the very ugly SIP api to recover a pointer to
>>>> the
>>>> actual C++ QObject.
>>>>
>>>> Does anyone know how recover the C++ QObject from the PyObject in
>>>> PySide?
>>> You can use:
>>> Shiboken::Object::cppPointer(...), it's on libshiboken basewrapper.h
>>>
>>> It receives two parameters, a SbkObject* and a PyTypeObject*, the
>>> SbkObject* will be your PyObject*, just cast it and make sure it always
>>> will be a Python object representing a C++ object bound using Shiboken,
>>> the
>>> PyTypeObject* must be the PyTypeObject* for QObject, you can get it using:
>>>
>>> Shiboken::TypeResolver::get("QObject*")->pythonType();
>>>
>>> TypeResolver class is located on libshiboken typeresolver.h header.
>>>
>>> Hope this would help you.
>> Yes, thanks, this seems to be just what i needed. You even provided answer
>> to what i wanted to ask next, how to identify pyside objects. No time to
(Continue reading)

David García Garzón | 3 Sep 03:48 2012

Re: Obtaining QObject from PySide based PyObject (complete)

On 28/08/12 16:25, Hugo Parente Lima wrote:
> On Tuesday, August 28, 2012 02:48:32 PM David García Garzón wrote:
>> On Monday 27 August 2012 16:23:03 Hugo Parente Lima wrote:
>>> On Monday, August 27, 2012 09:12:27 PM David García Garzón wrote:
>>>> Sorry for the previous unfinished message. Here goes the final one.
>>>>
>>>> I am porting a CPython library (boost based indeed) from PyQt to PySide.
>>>> I had a function in the library that received a Sip wrapped widget
>>>> as a PyObject and I used the very ugly SIP api to recover a pointer to
>>>> the
>>>> actual C++ QObject.
>>>>
>>>> Does anyone know how recover the C++ QObject from the PyObject in
>>>> PySide?
>>> You can use:
>>> Shiboken::Object::cppPointer(...), it's on libshiboken basewrapper.h
>>>
>>> It receives two parameters, a SbkObject* and a PyTypeObject*, the
>>> SbkObject* will be your PyObject*, just cast it and make sure it always
>>> will be a Python object representing a C++ object bound using Shiboken,
>>> the
>>> PyTypeObject* must be the PyTypeObject* for QObject, you can get it using:
>>>
>>> Shiboken::TypeResolver::get("QObject*")->pythonType();
>>>
>>> TypeResolver class is located on libshiboken typeresolver.h header.
>>>
>>> Hope this would help you.
>> Yes, thanks, this seems to be just what i needed. You even provided answer
>> to what i wanted to ask next, how to identify pyside objects. No time to
(Continue reading)


Gmane