O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

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

QVariant

QVariant is a class that can hold values of multiple types:

QVariant intValue = 1;int x = intValue.toInt();QVariant stringValue = "ok";QString y = stringValue.toString();

When you assign a value to a QVariant object, that value is stored inside along with the type information. You can use its type() method to find out which type of value it holds. The default constructor of QVariant creates an invalid value that you can detect using the isValid() method.

QVariant supports a great amount of types, including Qt value types such as QDateTime, QColor, and QPoint. You can also register your own types to store them in QVariant. One of the most powerful features of QVariant is the ability to store a collection or a hierarchy of values. ...

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