#include#include int main() { QVariant var(42); qDebug() << var; // Prints "QVariant(int, 42)" var.clear(); qDebug() << var; // Prints "QVariant()" return 0; }
#includeIn this example, we create a QVariantList object with three different types of values. We print the value of the list and then call the clear() function to remove all values from the list. Package/Library: Qt#include int main() { QVariantList list; list << 1 << "two" << true; qDebug() << list; // Prints "QVariantList(1, 2, 3)" list.clear(); qDebug() << list; // Prints "QVariantList()" return 0; }