QVariant value = 42; int intValue = value.toInt(); // intValue now contains the value 42
QVariantList list; list.append(42); list.append("Hello world"); list.append(true);This example demonstrates how QVariant can be used to store a list of values of different types. In this case, the list contains an integer, a string, and a boolean value. The `append()` function is used to add each value to the list. Package/Library: QVariant is part of the Qt Core module, which is a core library of the Qt framework. It is included in the standard Qt distribution and does not require any additional packages or libraries.