xervith
17th March 2014, 10:22
Hi.
What I'm trying to do is load list of accounts from database to QlistWidget,then when I right click on account, a context menu pops out.
After I choose "Manage User", I want to get text from selected row and pass it to the open form.
Everything works well,the only problem is,that i have no idea how to get text form row using pos
A little bit of code:
QString RMClass::ShowCXmenu(const QPoint& pos){
/////////////////////////////////////////////////////////////////////////////////////////////
openUsrMgr_WND = new QAction(tr("Manage User"),this);
openUsrMgr_WND->setShortcut(QKeySequence::Open);
// openUsrMgr_WND->setStatusTip(tr(""));
connect(openUsrMgr_WND, SIGNAL(triggered()),this, SLOT(USRMGR()));
/////////////////////////////////////////////////////////////////////////////////////////////
//USRDELETE = new QAction(tr("Delete User"), this);
//usrmgg->setShortcut(QKeySequence::New);
// USRDELETE->setStatusTip(tr(""));
// connect(USRDELETE, SIGNAL(triggered()),this, SLOT(USRDEL()));
//////////////////////////////////////////////////////////////////////////////////////////////
QMenu myMenu;
myMenu.addAction(openUsrMgr_WND);
myMenu.addSeparator();
// myMenu.addAction(USRDELETE);
myMenu.exec(QCursor::pos());
return UserNameCX; //that should return text from selected row
}
I also tried:
UserNameCX = ui->listWidget->currentItem()->text();
But everytime i right click inside listWidget program crashing
Thanks in advance
xer
What I'm trying to do is load list of accounts from database to QlistWidget,then when I right click on account, a context menu pops out.
After I choose "Manage User", I want to get text from selected row and pass it to the open form.
Everything works well,the only problem is,that i have no idea how to get text form row using pos
A little bit of code:
QString RMClass::ShowCXmenu(const QPoint& pos){
/////////////////////////////////////////////////////////////////////////////////////////////
openUsrMgr_WND = new QAction(tr("Manage User"),this);
openUsrMgr_WND->setShortcut(QKeySequence::Open);
// openUsrMgr_WND->setStatusTip(tr(""));
connect(openUsrMgr_WND, SIGNAL(triggered()),this, SLOT(USRMGR()));
/////////////////////////////////////////////////////////////////////////////////////////////
//USRDELETE = new QAction(tr("Delete User"), this);
//usrmgg->setShortcut(QKeySequence::New);
// USRDELETE->setStatusTip(tr(""));
// connect(USRDELETE, SIGNAL(triggered()),this, SLOT(USRDEL()));
//////////////////////////////////////////////////////////////////////////////////////////////
QMenu myMenu;
myMenu.addAction(openUsrMgr_WND);
myMenu.addSeparator();
// myMenu.addAction(USRDELETE);
myMenu.exec(QCursor::pos());
return UserNameCX; //that should return text from selected row
}
I also tried:
UserNameCX = ui->listWidget->currentItem()->text();
But everytime i right click inside listWidget program crashing
Thanks in advance
xer