You can select the item on to which the user has right-clicked and then change the text. Here's the code
void MyProgram
::customContentsMenu( const QPoint &pos
) {
if (!item)
return;
ui.treeWidget->setCurrentItem(item);
menu->exec(ui.treeWidget->viewport()->mapToGlobal(pos));
}
void MyProgram::RegisterMenu()
{
if(item)
item->setText("Text that you want");
}
void MyProgram::customContentsMenu( const QPoint &pos )
{
QTreeWidgetItem *item = ui.treeWidget->itemAt(pos);
if (!item)
return;
ui.treeWidget->setCurrentItem(item);
menu->exec(ui.treeWidget->viewport()->mapToGlobal(pos));
}
void MyProgram::RegisterMenu()
{
QTreeWidgetItem *item = ui.treeWidget->currentItem();
if(item)
item->setText("Text that you want");
}
To copy to clipboard, switch view to plain text mode
Bookmarks