Solved QCheckBox does not maintain its state in QWizard
-
I have a QWizard with mutiple pages. When I tick the check box and then click Back and Next buttons of QWizard, the check box becomes unticked. How can I persist check box state in QWizard when I move back and forth across pages in the QWizard?
-
You could subclass
QWizardPage
, save the button states and restore them, when you go back.Since
QWizard
is aQDialog
I'm wondering why the state of the pages isn't saved by default.
(If you create a newQDialog
, hide it and show it again, all buttons and text input stay the same, as long as you don't destroy the object or accept/reject the dialog) -
@mahesh_j
Do you uncheck the checkbox inQWizardPage::initializePage()
orQWizardPage::cleanupPage()
? -
@Bonnie no. I don’t have override for any of those functions for my page.
-
-
@Bonnie I did not have QWizard::IndependentPages option set. But when I set it to true, it fixed my issue. However, other pages depended on initializePage being called every time the page is being displayed, so they started misbehaving after setting the QWizard::IndependentPages option. I ended up overriding the QWizardPage::cleanupPage() and keeping it empty. This solved the issue. Thanks.