Hi i am trying to do one project like webrtc but in small. In this chat i will have users connected and offline. I tried to do one easy example with QTreeWidget still i'm trying to solve this issue. My problem is when i add a new contact in my account, the contact old is deleted and the new is created. The problem is when i add the child.
Code:
Qt Code:
  1. logado = true; //contacts
  2. ui->frameLogin->show();
  3. ui->frameConexion->show();
  4. int i,j;
  5. QStringList contactos = cliente.rosterManager().getRosterBareJids();
  6. for(i=0;i<contactos.length();i++)
  7. {
  8. item->setText(0,contactos[i]);
  9. QStringList recursos = cliente.rosterManager().getResources(contactos[i]);
  10. QIcon online;
  11. online.addFile(":/icons/user-offline.png");
  12. item->setIcon(0,online);
  13. for(j=0;j<recursos.length();j++)
  14. {
  15. item->addChild(item);
  16. item->child(j)->setText(0,recursos[j]);
  17. online.addFile(":/icons/user-online.png");
  18. item->setIcon(0,online);
  19. item->child(j)->setIcon(0,online);
  20.  
  21.  
  22. }
  23. listaItems.append(item);
  24. }
  25. ui->arbolConectados->addTopLevelItems(listaItems);
To copy to clipboard, switch view to plain text mode 
Any idea is good. It's only in the child doesnt add me one child insted of create me a new child and delete me the old.