Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Application Development with Qt Creator - Second Edition
  • Toc
  • feedback
Application Development with Qt Creator - Second Edition

Application Development with Qt Creator - Second Edition

4 (25)
close
Application Development with Qt Creator - Second Edition

Application Development with Qt Creator - Second Edition

4 (25)

Overview of this book

This book is great for developers who are new to Qt and Qt Creator and who are interested in harnessing the power of Qt for cross-platform development. If you have basic experience programming in C++, you have what it takes to create engaging cross-platform applications using Qt and Qt Creator!
Table of Contents (15 chapters)
close
14
Index

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, it will use a comma instead. The number method is a handy one, with overloads taking doubles and floats as well as integers and arguments to indicate the precision and exponentiation of the returned string.

Now, we move on...

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete