this is done in like 3 mins...
MyTreeWidget::MyTreeWidget(...)
{
// ...
// ...
}
void MyTreeWidget::populate(...)
{
// ...
item->setUserData(0,Qt::UserRole, PAGE_ID) ; // unique ID HERE
addTopLevelItem(item) ;
// ...
}
{
int id = item->data(0,Qt::UserRole).toInt() ;
emit currentIDChanged(id) ;
}
MyTreeWidget::MyTreeWidget(...)
{
// ...
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(currentItemChanged(QTreeWidgetItem*)))
// ...
}
void MyTreeWidget::populate(...)
{
// ...
QTreeWidgetItem *item = new QTreeWidgetItem("tree_item") ;
item->setUserData(0,Qt::UserRole, PAGE_ID) ; // unique ID HERE
addTopLevelItem(item) ;
// ...
}
void MyTreeWidget::currentItemChanged(QTreeWidgetItem * current)
{
int id = item->data(0,Qt::UserRole).toInt() ;
emit currentIDChanged(id) ;
}
To copy to clipboard, switch view to plain text mode
MyWindow::MyWindow(...)
{
// MyTreeWidget *p_treeWidget
// QStackedWidget *p_stackedWidget
// ...
connect(p_treeWidget, SIGNAL(currentIDChanged(int)), p_stackedWidget, SLOT(setCurrentIndex(int))) ;
// ...
}
MyWindow::MyWindow(...)
{
// MyTreeWidget *p_treeWidget
// QStackedWidget *p_stackedWidget
// ...
connect(p_treeWidget, SIGNAL(currentIDChanged(int)), p_stackedWidget, SLOT(setCurrentIndex(int))) ;
// ...
}
To copy to clipboard, switch view to plain text mode
Bookmarks