-
Book Overview & Buying
-
Table Of Contents
Qt5 C++ GUI Programming Cookbook
By :
Qt provides a set of classes and functions for easily converting between different types of data. This makes Qt more than just a GUI library; it is a complete platform for software development. The QVariant class, which we will be using in the following example, makes Qt even more flexible and powerful compared to similar conversion functionalities provided by the C++ standard library.
Let's learn how to convert various data types in Qt by following these steps:
Open up Qt Creator and create a new Qt Console Application project by going to File | New File or Project:

Next, open up main.cpp and add the following headers to it:
#include <QCoreApplication> #include <QDebug> #include <QtMath> #include <QDateTime> #include <QTextCodec> #include <iostream>
Then, in the main() function, add the following code to convert a string to a number:
int numberA = 2; QString numberB = "5"; qDebug() << "1) " << "2 + 5 =" << numberA...