[Qt-interest] QWizardPage::wizard() overprotected?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Thu Dec 11 12:09:06 CET 2008
Niels Dekker - no return address wrote on Thursday, December 11, 2008 10:01 AM:
> When implementing a wizard, I got a compile error, trying to call a
> protected member function, QWizardPage::wizard(). Which should just
> get me a pointer back from any wizard page to the wizard itself. Why
> isn't it public?
>
> Anyway, I was so lucky to find a trick to get access to a protected
> function, in a standard compliant and platform independent way. In an
> article by Alexander Nasonov, Overload (ACCU), December 2005:
> /// Returns the wizard associated with the specified page.
{code which shows how to implement a "delegate"}
> Please don't tell anyone ;-)
Well, that's not a big secret. But I'll tell you another one which is standard compliant and platform independent as well - and it is *way more hackish, easier and evil* than your "solution":
// muahahahahaaa (*evil laughter*)
#define private public
#define protected public
#include "TheClassToWhichYouWantToHaveAccessToTheHiddenMembers.h"
void ReallyEvilAndBadClass::doNastyStuff() {
TheClassToWhichYouWantToHaveAccessToTheHiddenMembers unlockedClass;
unlockedClass.callWhateverYouWant();
...
}
Don't blame /me/ when you shoot yourself into your knee (and blow away your entire body). Isn't C++ nice?
>;)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list