[C++-sig] Can boost.python and PyQt be used together?
dave at boost-consulting.com
Mon Dec 9 01:31:53 CET 2002
"Paul F. Kunz" <Paul_Kunz at SLAC.Stanford.EDU> writes:
>>>>>> On Sun, 08 Dec 2002 18:04:37 -0500, David Abrahams <dave at boost-consulting.com> said:
>> Err, Paul: when I suggested that you use return_internal_reference<>
>> for your newCanvas call, I didn't mean that you should blindly
>> substitute it for reference_existing_object everywhere!
>> You probably shouldn't be using call policies until you understand
>> what these things do. What is unclear when you RTFM? I mean, in
>> particular, the 3 sections starting here:
> Upon reading them again, I'm not sure. But...
> - the example for `return_internal_reference' looked like my case, but
> now I realize it is for a member function not a global function.
> My mistake.
Did you read
or did you just look at the example usage?
> - The example for `reference_existing_object' seems to be in error.
> it is not a template argument for `return_value_policy'.
Yes, that's been fixed in CVS for quite some time:
> Ok, so now I have...
> def ( "WCFactory", WCFactory,
> return_value_policy < reference_existing_object > () );
> class_ <WindowController> ( "WindowController" )
> .def ( "newCanvas",
> ( CanvasWindow * ( WindowController::* ) // function pointer
> (void) ) // arguments
> return_internal_reference <> () )
> So if I understand it, the *this, ie the WindowController object owns
> the returned CanvasWindow, which is what I want.
Actually, the returned CanvasWindow Python object owns the
WindowController, which is what you want ;-)
It's a little counterintuitive, but that's correct.
> I think the problem is not in Boost.Python incompatiblity, but in
> my code. I think my Window is trying to do something before the Qt
> application object is running. I'll have write some more code to
> test that.
> Thanks again for all your help, David and Phil.
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
More information about the Cplusplus-sig