Hi all,<br>
<br>
I changed the wrapping approach to the wrapper<...>, and with some ajustments it worked. <br>
<br>
I will display the code (just the essential part) below:<br>
<br>
<font size="1"><span style="font-family: courier new,monospace;">struct QObject_Wrapper: QObject, wrapper<QObject></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{<br>
// notice that I have overloaded constructors<br>
// so I have to redefine them<br style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;"> QObject_Wrapper(): </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> QObject()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> QObject_Wrapper(QObject* parent):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> QObject(parent)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bool</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> event(QEvent* p0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> if (override event = this->get_override("event"))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {<br>
// here is the trick. "event" is a Python object<br>
// not a real C++ funcion<br style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;"> return event( ptr( p0 ) );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return QObject::event(p0);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bool</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> default_event(QEvent* p0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> return this->QObject::event(p0);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">};</span></font> <br>
<br>
<font style="font-family: courier new,monospace;" size="1">void<br>
export_QObject()<br>
{ <br>
class_<QObject_Wrapper,<br>
boost::shared_ptr<QObject_Wrapper>,<br>
boost::noncopyable><br>
("QObject")<br>
<br>
// constructor with no parent<br>
.def(init<>())<br>
<br>
// constructor with QObject parent<br>
.def(init<QObject*>( args("parent") )<br>
[with_custodian_and_ward<1,2>()] )<br>
<br>
.def("event", &QObject::event, &QObject_Wrapper::default_event)<br>
;<br>
}</font><br>
<br>
So, it solved the problem. The only thing that I am concerned about, is
how does it know to convert native "QObject" to the "QObject_Wrapper".
Well its working well anyway. BTW, Pyste must be updated for that
wrapper<...> use.<br>
<br>
Thanks everybody. I am enjoying Boost.Python more everyday :)<br>
<br>
[Eric Jardim]<br>