QStandardItem is a class in the Qt GUI toolkit that represents an item in a standard model. The setData() function of QStandardItem is used to set the data of the item.
Here are some code examples using cpp QStandardItem setData() function:
Example 1:
QStandardItem* item = new QStandardItem("Hello World"); item->setData(QFont("Arial", 12), Qt::FontRole);
This example creates a QStandardItem with the label "Hello World". The setData() function is then used to set the font of the item to Arial with a size of 12.
Package library: Qt5Core
Example 2:
QStandardItem* item = new QStandardItem("Item"); item->setData(QColor(Qt::red), Qt::DecorationRole);
This example creates a QStandardItem with the label "Item". The setData() function is used to set the decoration role of the item to a red color.
Package library: Qt5Gui
Example 3:
QStandardItem* item = new QStandardItem("Item"); item->setData(QVariant(100), Qt::UserRole);
This example creates a QStandardItem with the label "Item". The setData() function is used to set the user role of the item to an integer value of 100.
Package library: Qt5Core
C++ (Cpp) QStandardItem::setData - 30 examples found. These are the top rated real world C++ (Cpp) examples of QStandardItem::setData extracted from open source projects. You can rate examples to help us improve the quality of examples.