1

I have ran into an issue. My GUI contains two treeWidgets with some push buttons. The first treeWidget lists out the files and the corresponding path of the folder in two separate columns. The second treeWidget adds and deletes single item using push buttons. Now if the user wants the facility of Ctrl+RightClick then how to incorporate the same.

Also I'm facing the duplication of items in the second treeWidget i.e. once the item is selected in first treeWidget, I can't restrict the addition of that item several times in second treeWidget. The code blocks are:

void Dialog::pushAdd_clicked()
{
    QTreeWidgetItem *item_1 = ui->treeWidget->currentItem();

    ui->treeWidget_2->addTopLevelItem(new QTreeWidgetItem(*item_1));
}

void Dialog::pushDelete_clicked()
{
    QTreeWidgetItem *item_2 = ui->treeWidget_2->currentItem();

    delete item_2;
}

Kindly note that I'm using treeWidget, not treeView.

Pride Leo
  • 13
  • 4

1 Answers1

0

You probably want to cal setSelectionMode

see more details here

Community
  • 1
  • 1
Abhishek Bansal
  • 5,197
  • 4
  • 40
  • 69
  • This seems to show some peculiar behavior which I'm not able to figure out. Suggest me some other method. – Pride Leo Mar 26 '14 at 04:50