By the time nextId
is called, you're already committed to switching the page. It simply doesn't make sense to do any validation at that point.
It is in fact a semantic error to have a nextId
implementation perform any validation, or display any user interface. It can be called as many times as the implementation wishes, and your code should cope with it. Just think about what this method is equivalent to. It's a query method not unlike the size
method on a container.
To validate the inputs, you should ideally reimplement isComplete
, or declare mandatory fields, or reimplement validateCurrentPage
.
validateCurrentPage
is called by QWizard::next
. If it returns true, then nextId
is called to query the page to switch to, and the pages are switched. The private switchToPage
code calls nextId
again to verify that the next page isn't invalid. That's the source of the double call that you experience.
Your checkSettings
calls don't belong in nextId
at all. They belong in validateCurrentPage
.
Qt source code is conveniently available through the woboq source code browser. Sometimes source code is better than any documentation. If you believe that the documentation is incomplete, I'm sure a well-done contribution that fixes the deficiency will be gladly accepted :)