Results 1 to 2 of 2

Thread: item new created old not appear in my QTreeView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2016
    Posts
    61
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default item new created old not appear in my QTreeView

    The problem is when i add item the old item was deleted why?
    code:
    Qt Code:
    1. void MainWindow::cambioRoster(QString barejid, QString resource)
    2. {
    3. if(cliente.rosterManager().isRosterReceived() == true)
    4. {
    5. QXmppPresence::Type a = cliente.rosterManager().getPresence(barejid,resource).type();
    6. QIcon online;
    7. online.addFile(":/icons/user-online.png");
    8. if(ui->arbolConectados->findItems(barejid,Qt::MatchExactly).size() == 0)
    9. {
    10. item->setText(0,barejid);
    11. ui->arbolConectados->addTopLevelItem(item);
    12. }
    13. if(a == QXmppPresence::Available)
    14. {
    15. item->setText(0,resource);
    16. item->setIcon(0,online);
    17. ui->arbolConectados->findItems(barejid,Qt::MatchExactly)[0]->addChild(item);
    18. }
    19. if(a == QXmppPresence::Unavailable)
    20. {
    21. int i=0;
    22. while(i<ui->arbolConectados->findItems(barejid,Qt::MatchExactly)[0]->childCount() && ui->arbolConectados->findItems(barejid,Qt::MatchExactly)[0]->child(i)->text(0) != resource) //busqueda lineal
    23. {
    24. i++;
    25. }
    26. ui->arbolConectados->findItems(barejid,Qt::MatchExactly)[0]->takeChild(i);
    27. if(ui->arbolConectados->findItems(barejid,Qt::MatchExactly)[0]->childCount() == 0)
    28. {
    29. online.addFile(":/icons/user-offline.png");
    30. }
    31. }
    32. ui->arbolConectados->findItems(barejid,Qt::MatchExactly)[0]->setIcon(0,online);
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by SirJonas; 16th October 2016 at 21:25.

Similar Threads

  1. Help with QTreeWidget list of contacts XMPP
    By SirJonas in forum Newbie
    Replies: 8
    Last Post: 16th October 2016, 07:28
  2. Error again with xmpp in qt 5.2
    By davinciomar in forum Newbie
    Replies: 12
    Last Post: 28th August 2016, 00:19
  3. Replies: 2
    Last Post: 21st February 2014, 20:21
  4. QTreeView: include root in tree?
    By meter in forum Newbie
    Replies: 2
    Last Post: 14th June 2010, 12:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.