- My QListWidgetItem array does not go out of scope
Okay here the code snippet which may be of interest.
qDebug("inside updatelist");
quint8 qIndex;
ui->listWidget->setWrapping(false);
// ui->listWidget->clear();
qDebug()<<"total items = "<<tot_items;
for (qIndex = 0; qIndex < tot_items; ++qIndex)
{
qDebug("inside for loop");
QString item_val
= QString(ItemsInList
[qIndex
].
name).
append("\n").
append(QString("$").
append(ItemsInList
[qIndex
].
price));
qDebug()<<"list widget string to be populated = "<<item_val;
item[qIndex].setText(item_val);
item
[qIndex
].
setIcon(QIcon(icon
));
ui->listWidget->addItem(&item[qIndex]);
}
ui->listWidget->setFocus();
qDebug("inside updatelist");
quint8 qIndex;
ui->listWidget->setWrapping(false);
// ui->listWidget->clear();
qDebug()<<"total items = "<<tot_items;
for (qIndex = 0; qIndex < tot_items; ++qIndex)
{
qDebug("inside for loop");
QString item_val = QString(ItemsInList[qIndex].name).append("\n").append(QString("$").append(ItemsInList[qIndex].price));
qDebug()<<"list widget string to be populated = "<<item_val;
item[qIndex].setText(item_val);
QString icon = QString("/home/charvi123/QtSDK/Projects/scanIt/numbers/") + QString("%1").arg((qIndex + 1), 0, 10) + QString(".png");
item[qIndex].setIcon(QIcon(icon));
ui->listWidget->addItem(&item[qIndex]);
}
ui->listWidget->setFocus();
To copy to clipboard, switch view to plain text mode
typedef struct _Item_list_entity
{
}ListItemSingle;
ListItemSingle ItemsInList[ITEMS];
QListWidgetItem item[MAX_ITEMS];
typedef struct _Item_list_entity
{
QString name;
QString price;
}ListItemSingle;
ListItemSingle ItemsInList[ITEMS];
To copy to clipboard, switch view to plain text mode
Bookmarks