QbelcorT
29th July 2009, 03:08
Hi,
I created a QTableWidget to illustrate the available wireless networks. The rowCount will be dynamic depending on number of networks. CellList is just text names I create before entering this loop.
My concern is using the 'new' for the QTableWidgetItem. It is possible this routine to populate the table will be called on a button press to refresh.
How or when should I delete (release) the memory?
Will QTableWidget::clearContents() accomplish this?
for (int i = 0; i < rowCount; i++ )
{
QTableWidgetItem *__essidName = new QTableWidgetItem(CellList[i][1].at(0));
uiWireless->availableNetworksTable->setItem(i,0,__essidName);
QTableWidgetItem *__strengthValue = new QTableWidgetItem(CellList[i][6].at(0));
uiWireless->availableNetworksTable->setItem(i,1,__strengthValue);
}
I created a QTableWidget to illustrate the available wireless networks. The rowCount will be dynamic depending on number of networks. CellList is just text names I create before entering this loop.
My concern is using the 'new' for the QTableWidgetItem. It is possible this routine to populate the table will be called on a button press to refresh.
How or when should I delete (release) the memory?
Will QTableWidget::clearContents() accomplish this?
for (int i = 0; i < rowCount; i++ )
{
QTableWidgetItem *__essidName = new QTableWidgetItem(CellList[i][1].at(0));
uiWireless->availableNetworksTable->setItem(i,0,__essidName);
QTableWidgetItem *__strengthValue = new QTableWidgetItem(CellList[i][6].at(0));
uiWireless->availableNetworksTable->setItem(i,1,__strengthValue);
}