1

I've created QToolBar which contains few QToolButton. Each QToolButton has QMenu which is one for all. And this menu has few actions.

Ugly example:

QToolBar bar;

QMenu menu;
QAction action1;
menu.addAction(action1);
QAction action2;
menu.addAction(action2);

QToolButton b1;
b1.setMenu(menu);
bar.addWidget(&b1);

QToolButton b2;
b2.setMenu(menu);
bar.addWidget(&b2);

So my question is next: How to know what QToolButton opens menu and perform menu action.

Example

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • 1
    Possible duplicate of [PyQT button clicked name](http://stackoverflow.com/questions/13050810/pyqt-button-clicked-name) – mmd1080 May 11 '17 at 17:31
  • I've solved it connecting QToolButton::clicked() signal to slot buttonIndexClicked(). After clicking function buttonIndexClicked() saves index of button which was clicked. This index we use to define who opens the menu. – Patrik Vons May 15 '17 at 11:37

0 Answers0