No rows are added (or are there no added ones?) In QStandardItemModel .
Here is the actual code:
QStandardItem * pProduct = new QStandardItem("3"); pProduct->setData("product", strProductName); this->appendRow(pProduct); QList<QStandardItem *> entries = this->findItems("product"); qDebug() << entries.count(); And accordingly, the output is always 0 . What am I doing wrong? How to add and get back the string?
UPD: it was possible to localize the problem:
QStandardItem * pChildEntry = new QStandardItem(QString("name")); pChildEntry->setData(QString("product"), strProductName); model.appendRow(pChildEntry); qDebug() << model.rowCount(); QList<QStandardItem *> entries = model.findItems(QString("product")); entries.count(); The number of lines displays normally, hence the search does not work, not the addition of lines
void QStandardItem::setData(const QVariant & value, int role = Qt::UserRole + 1). What does the second parameter mean in your code? - user194374