Results 1 to 5 of 5

Thread: QTreeWidgetItem, selecting and removing

  1. #1
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeWidgetItem, selecting and removing

    Hi

    I have problem because i dont know how to select item from QTreeWidget... i got this problem cause "item" is all time overwriting...

    Qt Code:
    1. item = new QTreeWidgetItem;
    2. item->setText(0,temp[0]);
    3. item->setText(1,QTime::currentTime().toString());
    4. item->setText(2,liczby);
    5. TWlist->addTopLevelItem(item);
    To copy to clipboard, switch view to plain text mode 

    And i dont know how to delete item, wich name is "text"...
    Qt Code:
    1. if(item->text(0)=="test")
    To copy to clipboard, switch view to plain text mode 
    ofcourse i know function removeItemWidget();, but i dont know how to find item wich name is "text"

    Best regards

    ps
    sry for my english in this post but i m very tired

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidgetItem, selecting and removing

    Quote Originally Posted by Zergi View Post
    I have problem because i dont know how to select item from QTreeWidget... i got this problem cause "item" is all time overwriting...
    Selected items and current items are relevant but different concept. However, you might want to use QTreeWidget::setCurrentItem().

    ofcourse i know function removeItemWidget();, but i dont know how to find item wich name is "text"
    See QTreeWidget::findItems() or QTreeWidgetItemIterator.

    ps
    sry for my english in this post but i m very tired
    Better take a nap then.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    Zergi (10th January 2008)

  4. #3
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidgetItem, selecting and removing

    EHh now i have another problem...

    Qt Code:
    1. while (*it) {
    2. if ((*it)->text(0) =="test"){
    3. TWlist->setItemSelected(*it, true);
    4.  
    5. }
    6. ++it;
    7. }
    8. //item = TWlist->currentItem ();
    9. TWlist->removeItemWidget(TWlist->currentItem (),0);
    To copy to clipboard, switch view to plain text mode 

    And i dont know why removeItemWidget dosent work... Do u know any else method to remove item from QTreeWidget?

    Best Regards

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidgetItem, selecting and removing

    "Item widgets" are something laid on top of items. You can simply delete the item.
    J-P Nurmi

  6. #5
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidgetItem, selecting and removing

    Can You tell something more ? Because i dont understand what u mean ;p
    Sry and thx for help

    Best Regads

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.