QVariant value; value.setValue(42); // set value to an integer
QVariant value; QString str = "hello"; value.setValue(str); // set value to a QString
QVariant value; QColor color(Qt::red); value.setValue(color); // set value to a QColorIn this example, we create a QVariant object and set its value to a QColor using the setValue function. The QVariant class is part of the QtCore library.