PDA

View Full Version : how to set Push Button PopMenu Signals?



augusbas
4th July 2009, 11:35
Hi I am creating a Push Button named "Start" with below Pop up menus

QMenu *menu=new QMenu();
menu->addAction("GPS");
menu->addAction("Serial Port");
menu->addAction("Browser");
pushButton->setMenu(menu);

Now when i click any one of the pop up menu how do i create signals for that?

i couldnt able to find signals for popup menu.

Please help

wysota
4th July 2009, 12:15
addAction() returns a QAction object that emits a QAction::triggered() signal when the action is activated.

augusbas
4th July 2009, 13:27
addAction() returns a QAction object that emits a QAction::triggered() signal when the action is activated.


Can you Please explain with a example how i do i connect a signal for the below action


QMenu *menu=new QMenu();
menu->addAction("Start");
pushButton->setMenu(menu);

We tried using the below connect :


connect(Start, SIGNAL(trigerred()), this, SLOT(startmenu()) );

It gave an error


error: ‘Start’ was not declared in this scope.

Please Help

wysota
4th July 2009, 13:40
QAction *Start = menu->addAction("Start");
connect(Start, SIGNAL(...), ..., SLOT(...));

augusbas
6th July 2009, 04:18
QAction *Start = menu->addAction("Start");
connect(Start, SIGNAL(...), ..., SLOT(...));


Thanks a lot Wysota , it worked out fantastically