altobeta
13th March 2009, 03:19
How to get the value from item treeWidget after i right click on the item and choose "Registration" option from popud menu
then item value will show up in TextEdit.
Please Someone see and modify my code
/MyProgram.cpp
///////////////////////////////////////////////////////////////
menu = new QMenu( this );
Register = new QAction(tr("Registration"), this);
connect(Register, SIGNAL(triggered()), qApp, SLOT(RegisterMenu()));
menu->addAction( Register);
ui.treeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
connect( ui.treeWidget, SIGNAL( customContextMenuRequested( const QPoint & )),
this, SLOT( customContentsMenu( const QPoint & )));
void MyProgram::customContentsMenu( const QPoint &pos )
{
QTreeWidgetItem *item = ui.treeWidget->itemAt(pos);
if (!item)
return;
menu->exec(ui.treeWidget->viewport()->mapToGlobal(pos));
}
void MyProgram::RegisterMenu()
{
//the textedit should show up the item value here which i select from right click item on TreeWidget, but i don't know how to get the value
}
then item value will show up in TextEdit.
Please Someone see and modify my code
/MyProgram.cpp
///////////////////////////////////////////////////////////////
menu = new QMenu( this );
Register = new QAction(tr("Registration"), this);
connect(Register, SIGNAL(triggered()), qApp, SLOT(RegisterMenu()));
menu->addAction( Register);
ui.treeWidget->setContextMenuPolicy( Qt::CustomContextMenu );
connect( ui.treeWidget, SIGNAL( customContextMenuRequested( const QPoint & )),
this, SLOT( customContentsMenu( const QPoint & )));
void MyProgram::customContentsMenu( const QPoint &pos )
{
QTreeWidgetItem *item = ui.treeWidget->itemAt(pos);
if (!item)
return;
menu->exec(ui.treeWidget->viewport()->mapToGlobal(pos));
}
void MyProgram::RegisterMenu()
{
//the textedit should show up the item value here which i select from right click item on TreeWidget, but i don't know how to get the value
}