O'Reilly logo

Application Development with Qt Creator by Ray Rischpater

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Wiring the Qt GUI application logic

The application logic for the calculator is simple: we add a property setter to the ResultDialog implementation that lets us set the result field of the dialog, and then wire up some arithmetic, signals, and slots in MainWindow to do the actual computation and show the dialog.

First, the 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, while if you do it with a locale set to a region where a comma is used as the decimal separator, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required