I am using QTreeWidget on the MainWindow and items are added to the TreeWidget from a table of a database.The tree has four rows and two columns.When i double click either the root or children on the specific row of the tree,then displays another widget.I am doing this using QModelIndex object.I want only the root of the row to "goes to" the specified widget and not the children.
My code is:
//Double click on the treeWidget
void MainWindow::changeSWidget(QModelIndex index)
{
//row 0
case Tree::Computers://1
ui->stackedWidget->setCurrentWidget(comp);
break;
case Tree::Files://1
ui->stackedWidget->setCurrentWidget(file);
break;
}
connect(Tree,SIGNAL(loadWidget(QModelIndex)),this, SLOT(changeSWidget(QModelIndex)));
How can i find which item is clicked ??Doing this when i clicked on each item is called the slot display.
//double click on treewidget items
connect(ui->treeWidget,SIGNAL(itemDoubleClicked(QTreeWidgetIt em*,int)),this,SLOT(display(QTreeWidgetItem*,int)) );
Is it better for me to use a model/view approach??
i hope you understand what i am saying..
Bookmarks