So if you delete items manually like this:
void MainWindow
::ParseMainscreen(QString mainstring
){ if(mainstring!=""){
const int count = arrVisDetails.count();
if( count ){
for( int i=ui->Monitor_tree->topLevelItemCount()-1; i>=0 ; --i ){
delete ui->Monitor_tree->takeTopLevelItem(i);
}
for( int i=0 ; i<count ; ++i ){
item->setText(0,arrVisDetails .at(i));
ui->Monitor_tree->addTopLevelItem(item);
}
}
}
}
void MainWindow::ParseMainscreen(QString mainstring){
if(mainstring!=""){
QStringList arrVisDetails = QString(mainstring).split("<fld>",QString::KeepEmptyParts,Qt::CaseInsensitive);
const int count = arrVisDetails.count();
if( count ){
for( int i=ui->Monitor_tree->topLevelItemCount()-1; i>=0 ; --i ){
delete ui->Monitor_tree->takeTopLevelItem(i);
}
for( int i=0 ; i<count ; ++i ){
QTreeWidgetItem * item = new QTreeWidgetItem();
item->setText(0,arrVisDetails .at(i));
ui->Monitor_tree->addTopLevelItem(item);
}
}
}
}
To copy to clipboard, switch view to plain text mode
memory still leaks ? This method looks ok (I assume that arrVisDetails.count!=0 is a typo), are you sure you are not doing something else in your code ?
Try to separate this method into another small app, this way you can see if its this method that leaks.
Bookmarks