Wiring the Qt Widgets' application logic
The application logic for the calculator is simple: we add a property setter to ResultDialog
that lets us set the result field of the dialog, and then we wire up some arithmetic, signals, and slots in MainWindow
to do the actual computation and show the dialog.
First, make the following change to ResultDialog
:
void ResultDialog::setResult(float r) { ui->result->setText(QString::number(r)); }
This method takes a float, the value to show in the dialog, and formats the result as a string using Qt's default formatting. Qt is fully internationalized; if you do this in English-speaking locales, it will use a decimal point, whereas if you do it with a locale set to a region where comma is used as the decimal separator, ...
Get Application Development with Qt Creator - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.