[C++-sig] How to wrap protected virtual methods

Eric Jardim ericjardim at gmail.com
Sat Aug 6 15:15:17 CEST 2005


Hi, everyone...

I think I solved this "problem". Actually, I think that there is no problem. 
I worked so much last night that I couldn't see the simple solution.

class QWidget_Wrapper: QWidget, wrapper<QWidget>
{
 void
 mousePressEvent(QMouseEvent* p0)
 {
 if (override mousePressEvent = this->get_override("mousePressEvent"))
 {
 mousePressEvent( ptr( p0 ) );
 }
 else
 {
 QWidget::mousePressEvent(p0);
 }
 }
 
void
 default_mousePressEvent(QMouseEvent* p0)
 {
 QWidget::mousePressEvent(p0);
 }
 ...
};

// and do
.def("mousePressEvent", &QWidget::mousePressEvent, 
&QWidget_Wrapper::default_mousePressEvent)

// instead of
.def("mousePressEvent", &QWidget_Wrapper::default_mousePressEvent)

So, solved another issue. But I think this should be noticed on some place 
of the docs or the tutorial itself.

[Eric Jardim]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20050806/48abf9f4/attachment.htm>


More information about the Cplusplus-sig mailing list