Firstly, thanks for your answer.
Sorry, maybe I have not explained well. Now I am creating a new QStandarItemModel and apply it with setModel. The problem is that creating a new QStandardItemModel is a long process because I'm doing it of this way:
class displayInformation .....
....
....
QStandardItemModel* displayInformation
::createModel(const QList<Data
*>
*dataList
) //This QStandardItemModel is seting by setModel() in QTreeView {//Data is a class that contain all information of each item and its chils to show it in QTreeView
int index = 0;
if(!dataList)
return model; //model is a QStandardItemModel*
if(dataList->size()==0){
model->setRowCount(0); index = 0; return model;}
if(dataList->size() < model->rowCount())//To remove a item
{
int check = 0;
for(int i=0;i<model->rowCount();i++)
{
showText = model->item(i)->text();
for(int j=0; j<buddies->size();j++)
{
if(showText == buddies->at(j)->getAddress().toString())
{
check=1;
break;
}
}//for
if(check!=1)
{
model->removeRow(i);//REMOVE THE ITEM
break;
}
return model;
}//If remove item
while(index < buddies->size())//To add item and its chils if it has them
{
if(dataList)
{
item = createItem(
dataList->at(index)->getAddress().toString(),
dataList->at(index)->getNumConnections())//I create the item whit its chils (connections)
model->setItem(index, item);
}
index++;
}
return model;
}//createModel
.....
....
class displayInformation .....
....
....
QStandardItemModel* displayInformation::createModel(const QList<Data *> *dataList) //This QStandardItemModel is seting by setModel() in QTreeView
{//Data is a class that contain all information of each item and its chils to show it in QTreeView
int index = 0;
if(!dataList)
return model; //model is a QStandardItemModel*
if(dataList->size()==0){
model->setRowCount(0); index = 0; return model;}
if(dataList->size() < model->rowCount())//To remove a item
{
int check = 0;
for(int i=0;i<model->rowCount();i++)
{
QString showText;
showText = model->item(i)->text();
for(int j=0; j<buddies->size();j++)
{
if(showText == buddies->at(j)->getAddress().toString())
{
check=1;
break;
}
}//for
if(check!=1)
{
model->removeRow(i);//REMOVE THE ITEM
break;
}
return model;
}//If remove item
while(index < buddies->size())//To add item and its chils if it has them
{
QStandardItem *item;
if(dataList)
{
item = createItem(
dataList->at(index)->getAddress().toString(),
dataList->at(index)->getNumConnections())//I create the item whit its chils (connections)
model->setItem(index, item);
}
index++;
}
return model;
}//createModel
.....
....
To copy to clipboard, switch view to plain text mode
If I want show 100 QProgressBar as children of text items and after update each prgress of each progress Bar when the signal byttesWritten is emited, my application must perform many calculations. How I can extract each item individually and apply changes?
Bookmarks