[Qt-interest] Setting text of Commit button in QWizard does not work?

Andre Somers andre at familiesomers.nl
Thu Apr 29 14:37:02 CEST 2010


On 29-4-2010 13:01, Frank Lutz wrote:
> Without any experiments on this:
>
> enum WizardButton { BackButton, NextButton, CommitButton, FinishButton,
> ..., Stretch }
> void QWizard::setButton ( WizardButton which, QAbstractButton * button );
>
> Sorry i do never have used it, so i can't give you better help.
>    
Sorry, but this is totally unhelpful.
As you can see in my first posting, I am completely aware of the enums 
to select the button. I wrote:

     button(QWizard::CommitButton)->setText(tr("Bar"));
     button(QWizard::NextButton)->setText(tr("Foo"));

The first does not work, the second does. This is on Windows XP 64 bit, using Qt 4.6.2 in 32 bits mode.

My observations:
1) Setting the text for a button does not work from the constructor
2) Setting the text for another button than the one that is currently shown, does not work
3) On page change, changes to button texts are destroyed
4) On navigating back, the changed button texts are destroyed

I infer:
1) You can only set texts for buttons that are currently shown.
2) Qt /seems/ to not actually use different buttons, but just replaces the texts on them.
3) QWizard::button() is not suitable for this manipulation

However, it turns out that QWizard offers a specialized method for setting the text, and that one *does* work as expected. Just using QWizard::setButtonText() did the trick.

I find it weird, that the documentation for QWizard::button() does not mention that whatever you change on the buttons, Qt is liable to change back at any time behind your back.

André












More information about the Qt-interest-old mailing list