Hey all,
Im using QTreeWidget and a QList to display some create items from user-input text.
code below:
QList<QTreeWidgetItem *> items;
repoList->insertTopLevelItems(0, items); //repoList= my QTreeWidget
QList<QTreeWidgetItem *> items;
items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(QString(repoText))));//repoText = user-input text
repoList->insertTopLevelItems(0, items); //repoList= my QTreeWidget
To copy to clipboard, switch view to plain text mode
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);
int x = items.indexOf(repoList->currentItem());
repoList->takeTopLevelItem(x);
To copy to clipboard, switch view to plain text mode
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));
//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));
To copy to clipboard, switch view to plain text mode
anyways, thank you for your time, and please help :_)
Bookmarks