PDA

View Full Version : connecting Pop up Menu List to actions/functions



ebsaith
18th June 2013, 09:01
Thanks.... Solved :)

anda_skoa
18th June 2013, 09:15
QAction has a triggered() signal which is emitted when the user activates the menu entry representing the action

Cheers,
_

ebsaith
18th June 2013, 09:46
This is what I have


void MainWindow::slPopUpMenu()
{
QMenu *newMenu = new QMenu(this);
newMenu->addAction(new QAction("Do that", this));
}

how do get to the slot of the created action
after it is triggered

Im not seeing it!

I even tried creating a action on the form, then I was able to go to slot
but that how do I add that action to my menu?

anda_skoa
19th June 2013, 07:43
This is what I have


void MainWindow::slPopUpMenu()
{
QMenu *newMenu = new QMenu(this);
newMenu->addAction(new QAction("Do that", this));
}

how do get to the slot of the created action
after it is triggered

Im not seeing it!


As I said, connect to the action's triggered() signal



QAction *action = new QAction("Do that", this));
connect(action, SIGNAL(triggered()), this, SlOT(doThatSlot()));
newMenu->addAction(action);


Cheers,
_