3.4. Exercises: Introduction to Qt

  1. Write a fuel consumption calculator that can convert in either direction between miles-per-gallon and liters-per-100km.

    For example, a car that can drive 34 miles on one (US) gallon of fuel will consume 6.92 liters of fuel if it is driven 100km.

    Feel free to use QInputDialog and QMessageBox as demonstrated in Section 1.11.

    solution/basicio/milespergallon

  2. Ask the user for a birthdate, and calculate her current age. Hints: use QInputDialog::getText(), convert result from QString to QDate, and compare to QDate::currentDate(). Alternately, you can create a dialog that presents a QDateEdit to get a proper date from the user.

    solution/basicio/birthday

[ fromfile: qtintro.xml id: None ]