I want to write a program that asks the user a series of questions in different dialog boxes. Each box shows up one at a time, and goes to the next box if the button next is clicked. My question is do I create a class for each Dialog and just call the next class once the button next is clicked? Or is there a more elegant solution to this?
Share
My recommendation is to build a base class that holds the current question, then when the user answers a question and advances to the next one, the base class updates the display of the new current question. You don’t need to destroy widgets at any point (except when quitting the application), and you can also reuse widgets before creating new ones.
Let me simplify the format of your questions to this one: each question contains a question description and a set of answers where the user can pick a single one. These simplifications can be removed, but I set them in order to present an initial code to deal with the problem.
Here is a starting point for doing exactly this (my imagination towards naming was weak):
And here is the GUI you will get: