[C++-sig] Can boost.python and PyQt be used together?

Paul F. Kunz Paul_Kunz at SLAC.Stanford.EDU
Mon Dec 9 00:59:28 CET 2002


>>>>> 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!

   Sorry.

> 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:
> http://www.boost.org/libs/python/doc/v2/reference.html#models_of_call_policies

   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.

- The example for `reference_existing_object' seems to be in error.
  it is not a template argument for `return_value_policy'.

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
	   &WindowController::newCanvas,
 	   return_internal_reference <> () )
    ;

So if I understand it, the *this, ie the WindowController object owns
the returned CanvasWindow, which is what I want.

   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.




More information about the Cplusplus-sig mailing list