[Qt-interest] removing items QTreeWidget

Mystical Groovy mysticalgr at gmail.com
Mon Nov 2 20:25:49 CET 2009


 Hey all,

Im using QTreeWidget and a QList to display some create items from
user-input text.

code below:
 Qt Code:





QList<QTreeWidgetItem *> items;

items.append(new QTreeWidgetItem
<http://doc.trolltech.com/latest/QTreeWidgetItem.html>((QTreeWidget
<http://doc.trolltech.com/latest/QTreeWidget.html>*)0,QStringList
<http://doc.trolltech.com/latest/QStringList.html>(QString
<http://doc.trolltech.com/latest/QString.html>(repoText))));//repoText
= user-input text
repoList->insertTopLevelItems(0, items); //repoList= my QTreeWidget

now i have a remove button that when the user clicks it i want it to remove
the currently selected item.

using the following code, items from the QTreeWidget are removed but not the
one ive clicked! ("!?!WTF...)
 Qt Code:



int x = items.indexOf(repoList->currentItem());
    repoList->takeTopLevelItem(x);

Ive also tried the following with no luck:
 Qt Code:







//with the following 2, the program compiles fine but nothing happens
when i choose an item and click the remove button.
    repoList->selectedItems().removeAt(x);
    repoList->currentItem()->takeChild(x);

//i get a bunch of errors using the following one...
    repoList->selectedItems().removeAll(repoList->currentItem()->text(0));

anyways, thank you for your time, and please help :_)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091102/dd0cc4ab/attachment.html 


More information about the Qt-interest-old mailing list