I suspect that I am trying to bend a QWizardPage to do more than it is supposed to which is why I am running into issues but maybe there is a way to do this.
So, I have a number of pages within a QWizard and on one certain page I run a series of tests against some hardware that then stores results in a database. I want to be able to cancel if necessary. However at the moment the Cancel button is part of the QWizard so i am not sure how to handle it.
I am aware I can overide the reject() function of QWizard and then determine the current page and if it is the page I am interested in then do something but I would rather not tie the pages togehter in this way unless I have to.
I did try to connect the rejected() signal to the wizard like this:
connect(this, SIGNAL(rejected()), ui->runTestPage, SLOT(on_rejected()));
But this instantly closes the page anyway before I can display anything back to the user to say I am cancelling.
I could add a button to the wizard page that will display when the test is running to allow a cancel but then the page still has the main cancel button. In fact even after the test is complete the Cancel still displays so being able to remove or disable that would seem appropriate.
So is this something I can do or do I need to revisit the entire use of a wizard?
Yes it’s doable. First you don’t necessarily need to override
rejected(), I’d go down the route of getting rid of theQWizardcancel button and instead insert your ownQPushButton(or whichever) pointing to your own slot, do your ‘cancelling now’ message box from there and then trigger therejected()slot.It’ll save you a lot of headaches from massaging the default signal/slots, and allow you to replace ‘Cancel’ with ‘Close’ which possibly makes more sense in the context of a wizard (depending on the wizard, functionality etc etc).