Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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?



  • @mahesh_j

    You could subclass QWizardPage, save the button states and restore them, when you go back.

    Since QWizard is a QDialog I'm wondering why the state of the pages isn't saved by default.
    (If you create a new QDialog, 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 in QWizardPage::initializePage() or QWizardPage::cleanupPage()?



  • @Bonnie no. I don’t have override for any of those functions for my page.



  • @mahesh_j
    Does

    setOption(QWizard::IndependentPages);
    

    do any change to that?



  • @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.


Log in to reply