1.10.1. Exercises: Qt dialogs for user input/output

These exercises in this section are all based on Example 1.12. Most of the answers can be found in the Qt Reference API Documentation.

[ fromfile: qtfirstapp.xml id: ex-qtfirstapp ]

  1. For the QInputDialog, we have a “cancel” button which is currently not being used. How would we fix this program so that it does not show the Cancel button?

  2. How would we fix the program so that it performs no calculation and exits the loop if the user clicks cancel?

  3. At the moment, it does not check if the user enters a negative number. How would you fix the program to ensure that negative numbers are never calculated?