[Qt-interest] QWizardPage::wizard() overprotected?
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Thu Dec 11 10:17:19 CET 2008
Since your deriving from WizardPage anyway.. why not just overload
wizard() and make it public?
That said, why do you need access to the wizard outside of the
WizardPage?
Scott
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Niels Dekker - no return address
> Sent: Thursday, December 11, 2008 1:01 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] QWizardPage::wizard() overprotected?
>
> 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:
> http://accu.org/index.php/journals/296 Hereby I'd like to share my
getWizard
> function with you:
>
> /// Returns the wizard associated with the specified page.
> QWizard* getWizard(const QWizardPage& page)
> {
> struct BreakProtection: QWizardPage
> {
> static QWizard* getWizard(const QWizardPage& page)
> {
> QWizard* (QWizardPage::*memberFunction)() const =
> &BreakProtection::wizard;
> return (page.*memberFunction)();
> }
> };
> // Calls the protected wizard() member function.
> return BreakProtection::getWizard(page);
> }
>
> Please don't tell anyone ;-)
>
> Kind regards,
>
> Niels
>
> --
> I need to make mistakes just to learn who I am
> And I don't wanna be so damn protected
> - Britney Spears, Overprotected
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list