QVariant var(QRect(10, 20, 30, 40)); QRect rect = var.toRect();
QVariantMap map; map.insert("rect", QRect(10, 20, 30, 40)); QRect rect = map.value("rect").toRect();In this example, we have a QVariantMap object that stores a QRect object with the key "rect". The value is retrieved using the value() function and then converted to a QRect object using the toRect() function. Package library: QtCore library.