Hello, I'm trying to make a list of all my contacts in my account. To do this, I will show those that are connected and not. I rely on the XMPP chat communication protocol. The code is as follows:
void MainWindow::rosterRecibido()
{
logado = true; //cuando recibimos el roster ya mostramos el frame con la lista de conectados
ui->frameLogin->hide();
ui->frameConexion->show();
int i,j;
QTreeWidgetItem *item = new QTreeWidgetItem();
QStringList contactos = cliente.rosterManager().getRosterBareJids();
for(i=0;i<contactos.length();i++)
{
item->setText(0,contactos[i]);
QStringList recursos = cliente.rosterManager().getResources(contactos[i]);
QIcon online;
online.addFile(":/icons/user-offline.png");
item->setIcon(0,online);
for(j=0;j<recursos.length();j++)
{
item->addChild(new QTreeWidgetItem());
item->child(j)->setText(0,recursos[j]);
online.addFile(":/icons/user-online.png");
item->setIcon(0,online);
item->child(j)->setIcon(0,online);
listaItems.append(item);
}
}
ui->arbolConectados->addTopLevelItems(listaItems);
}
What happens to me that when I add a contact the previous one is deleted even though I add it to the list. I repeat is based on the XMPP system.