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 aQPushButtonwidget to the form by dragging and dropping fourLabel, twoLine Edit, and aPush Buttonwidget onto the form. - Set the
textproperty of the firstLabelwidget toFind out the distance between two locations, that of the secondLabelwidget toEnter first location, and that of the thirdLabelwidget toEnter second location. - Delete the
textproperty of the fourthLabelwidget because itstextproperty will be set through code; that is, the distance between the two entered locations will be computed through...