[Qt-interest] QWizardPage::wizard() overprotected?
Anthony Serdyukov
uksus70 at gmail.com
Thu Dec 11 12:53:55 CET 2008
I'd suggest you to use signals and slots, it can help you connect
objects that doesn't know about each other.
2008/12/11, Niels Dekker - no return address <noreply at this.is.invalid>:
> Scott Aron Bloom wrote:
>> Since your deriving from WizardPage anyway.. why not just overload
>> wizard() and make it public?
>
> Thanks for your reply. So you say I'd have to override wizard() on all of
> my
> derived WizardPage classes, to make it public. But then why wasn't it
> public
> in the first place? I mean, what does Qt protect me against?
>
>> That said, why do you need access to the wizard outside of the
>> WizardPage?
>
> >From within any of my pages, I need to find my way back to the status bar
> of
> my wizard. Unfortunately, a QWizard cannot have a status bar, so I had to
> put
> it onto a QMainWindow. Anyway, to avoid code duplication, I wrote a single
> function to get the status bar belonging to my wizard:
>
> // Returns the status bar, specific to my application.
> QStatusBar& getStatusBar(const QWizardPage& page)
> {
> // Get the "protected" wizard from the page.
> const QWizard* const wizard = getWizard(page);
> assert(wizard != NULL);
>
> // My wizard has a QMainWindow as parent.
> const QMainWindow* const mainWindow =
> dynamic_cast<const QMainWindow *>(wizard->parent());
> assert(mainWindow != NULL);
>
> QStatusBar* statusBar = mainWindow->statusBar();
> assert(statusBar != NULL);
> return *statusBar;
> }
>
>
> Now I can directly get the status bar, from within any of my pages:
> getStatusBar(*this).showMessage(tr("Status okay!"));
>
> Doesn't that sound reasonable to you?
>
> Kind regards,
> --
> Niels Dekker
> http://www.xs4all.nl/~nd/dekkerware
> Scientific programmer at LKEB, Leiden University Medical Center
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Regards,
Anthony
More information about the Qt-interest-old
mailing list