Results 1 to 3 of 3

Thread: QTreeWidgetItem select different rows?

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

    Default QTreeWidgetItem select different rows?

    Hello i will have QList of my accounts and QTreeWidgetItem with the items of each account, my contact. However i can only select one contact, exists some way to select more number of contact's, not only one?
    code:
    Qt Code:
    1. QList<QTreeWidgetItem*> listaItems;
    2. int i,j;
    3. QStringList contactos = cliente.rosterManager().getRosterBareJids();
    4. for(i=0;i<contactos.length();i++)
    5. {
    6. item->setText(0,contactos[i]);
    7. QStringList recursos = cliente.rosterManager().getResources(contactos[i]);
    8. QIcon online;
    9. online.addFile(":/icons/user-offline.png");
    10. item->setIcon(0,online);
    11. for(j=0;j<recursos.length();j++)
    12. {
    13. item->addChild(new QTreeWidgetItem());
    14. item->child(j)->setText(0,recursos[j]);
    15. online.addFile(":/icons/user-online.png");
    16. item->setIcon(0,online);
    17. item->child(j)->setIcon(0,online);
    18. listaItems.append(item);
    19.  
    20. }
    21. ui->arbolConectados->addTopLevelItems(listaItems);
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QTreeWidgetItem select different rows?

    Set the selection mode
    Qt Code:
    1. treeWidget->setSelectionMode(QAbstractItemView::MultiSelection)
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Oct 2016
    Posts
    61
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTreeWidgetItem select different rows?

    in my case will be arbolConectados thx i will check it. I didnt include but arbolconectados is my treewidget!

Similar Threads

  1. Replies: 3
    Last Post: 5th April 2016, 09:23
  2. QTableView: Select multiple rows?
    By realdarkman71 in forum Newbie
    Replies: 2
    Last Post: 9th December 2010, 21:36
  3. QTreeView and multi-select of rows
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 27th October 2008, 02:32
  4. QTableWidget - Select multiple rows.
    By wally in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2008, 17:15
  5. select a QTreeWidgetItem
    By mattia in forum Newbie
    Replies: 2
    Last Post: 21st December 2007, 11:01

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.