QVariant var = 42; int value = var.toInt(); // value is now 42
QVariant var = "hello"; int value = var.toInt(); // value is now 0In this example, the QVariant contains a string value that cannot be converted to an integer. The toInt function returns 0 in this case. QVariant is a part of the QtCore library which is available in the Qt package.