Mystical Groovy
1st November 2009, 00:06
Hey all,
Im using QTreeWidget and a QList to display some create items from user-input text.
code below:
QList<QTreeWidgetItem *> items;
items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(QStrin g(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...)
int x = items.indexOf(repoList->currentItem());
repoList->takeTopLevelItem(x);
Ive also tried the following with no luck:
//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 :_)
Im using QTreeWidget and a QList to display some create items from user-input text.
code below:
QList<QTreeWidgetItem *> items;
items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(QStrin g(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...)
int x = items.indexOf(repoList->currentItem());
repoList->takeTopLevelItem(x);
Ive also tried the following with no luck:
//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 :_)