-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Saturday 29 June 2002 22:41 schrieb Stephen Allewell: > I have a class 'Editor' that is derived from QScrollView. QScrollView > has the function > QPoint contentsToViewport(const QPoint &p) to convert content > coordinates to viewport coordinates. > I also require to convert a QRect so I wrote the function: > > QRect Editor::contentsToViewport(QRect &r) { > return > QRect(contentsToViewport(r.topLeft()),contentsToViewport(r.bottomRight())); > } > > but when compiling I get the error that there is no matching function > for contentsToViewport(QPoint &) unless I explicitly use > QScrollView::contentsToViewport(...) which then compiles and works as > intended. > > I thought that it was possible to have different functions with the > same name as long as the parameters where different. > > Anyone have any idea why this doesn't work? Yes, a method in a derived class hides any method with the same name in the base class. You have two possibilities here: class Base { public: void doStuff( const QPoint& ); }; // Either: class Derived : public Base { public: void doStuff( const QPoint& p ) { Base::doStuff( p ); } void doStuff( const QRect& ); }; // Or, but doesn't work with older compilers: class Derived : public Base { public: using Base::doStuff; void doStuff( const QRect& ); }; - -- Malte Starostik PGP: 1024D/D2F3C787 [C138 2121 FAF3 410A 1C2A 27CD 5431 7745 D2F3 C787] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9Hg6kVDF3RdLzx4cRAg26AJsH5p8U+jM0vbQv5LtSXSZvcaC0QgCgomAc Jf/z+wWt749HMXuwJnF9m6w= =/185 -----END PGP SIGNATURE----- >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<