PDA

View Full Version : delete QStandardItem but allocated buffer not free



htyoung
22nd November 2010, 17:41
Hi,

I use QStandardItemModel to display some items.
But found a strange issue after allocated QStandardItem .

issue description:
I add a new item by allocated QStandardItem, like following:

///////////////// Code example 1 /////////////////////////////////

QStandardItemModel * m_itemModel = new QStandardItemModel(0, 2, this);;

QStandardItem * item1 =new QStandardItem("Test" );
QStandardItem * item2 =new QStandardItem("Test" );

QList <QStandardItem * >itemLits;
iteList.append(item1 );
iteList.append(item2 );
m_itemModel->appendRow(itemLits);

////////////////////end Code example 1 ///////////////////////////////////////////



Then I delete the item 1 and item2 like following:


///////////////// Code example 2 /////////////////////////////////
delete item1 ;
delete item2;

////////////////////end Code example 2 ///////////////////////////////////////////


But I found a issue, We can't release the buffer after delete item1 and item2.

It'means, the execute buffer fastly augment.

How can we delete the allocated QStandardItem , without memeory augment?


wya
23, Nov.2010