QGraphicsItem* item = new QGraphicsItem(); item->setData("color", "red");
QListitemList = scene->items(); foreach(QGraphicsItem* item, itemList) { item->setData("selected", false); }
QGraphicsItem* item = new QGraphicsItem(); MyObject* obj = new MyObject(); item->setData("custom_object", QVariant::fromValue(obj));Package library: Qt Overall, the setData method is a useful feature of the QGraphicsItem class in the Qt library to store additional data in items to use in different cases like getting and setting data, implementing custom behavior, and etc.