PDA

View Full Version : how can release the memory after closing tab widget?



aurora
14th February 2012, 05:56
I am using a tabwidget and adding tabs dynamically in runtime...
Each tab contains many widgets....
But if i close a tab, its memory is not releasing....how can i handle it?


code in adding tab


ui->tabWidget_unfiltered->addTab(filesTable,FileName);


aftr closing tab


ui->tabWidget_unfiltered->removeTab(index);




Here each tab contains a table widget....
And storing each those table in a hash table as
QHash<QString,QTableWidget*> StoredTables;

Hence when i delete that tab, i'm just removing this hash entry as..

StoredTables.remove(RmovedFilename);
but when i check in Task bar->memory(private eorking set) , the memory is not deallocating after closing the tab....
What should i do?

ChrisW67
14th February 2012, 06:23
Ummm, you delete it.


QWidget *tab = ui->tabWidget_unfiltered->widget(index);
ui->tabWidget_unfiltered->removeTab(index);
delete tab;

aurora
14th February 2012, 06:28
Ok thank u...how can i release the memory in hash table....?

ChrisW67
14th February 2012, 23:09
Empty the hash table (QHash::clear()), delete the hash table.... really depends on what you mean.