mapping menu item with QPushButton
Hi,
Can any one please tell, is it possible to map menu item with a normal button in the main window. For example:
Menu has a checkable sub item called EDIT and there is a QPushButton called EDIT in mainwindow . This both should synchronise i.e when i click subitem EDIT, then mainwindow EDIT should turn to checked state.
Can any one help me out????
Re: mapping menu item with QPushButton
is this what you what?
Code:
...
action->setCheckable(true);
QMenu *menu
= menuBar
()->addMenu
(tr
("File"));
menu->addAction(action);
pb->setCheckable(true);
connect(action, SIGNAL(toggled(bool)), pb, SLOT(setChecked(bool)));
connect(pb, SIGNAL(toggled(bool)), action, SLOT(setChecked(bool)));
...
Re: mapping menu item with QPushButton
but shouldn't this happen automatically when you would also add the action to the button? like:
Code:
pb->addAction(action);
it seems unintuitive to me that I would have to manually connect signal/slot if that would exactly seem like an advantage of using an action in multiple places that you don't have to connect it each time..?
in any case, I tried it by adding the action to the toggle button, but it doesn't work. So that's why I started searching the net and ended up here :) I just would like confirmation from a qt guru that manually connecting the signal/slot is the right thing to do..