Finding out the distance between two locations
In this recipe, you will learn how to find out the distance in kilometers between the two locations entered by the user. The recipe will simply prompt the user to enter two locations, followed by clicking the Find Distance
button, and the distance between the two will be displayed.
How to do it…
Let's create an application based on the Dialog without Buttons template by performing the following steps:
- Add four
QLabel
, twoQLineEdit
, and aQPushButton
widget to the form by dragging and dropping fourLabel
, twoLine Edit
, and aPush Button
widget onto the form. - Set the
text
property of the firstLabel
widget toFind out the distance between two locations
, that of the secondLabel
widget toEnter first location
, and that of the thirdLabel
widget toEnter second location
. - Delete the
text
property of the fourthLabel
widget because itstext
property will be set through code; that is, the distance between the two entered locations will be computed through...