Update: I had mis-typed part of my problem description. This is now corrected.
Consider:
//some container class
//initialization code
QAction *superCoolAction;
//action initialized to release some signal, SCA_Signal
//initialization code contains superCoolAction, it's parent is this container class
a->addMenu(sharedMenu);
b->addMenu(sharedMenu);
c->addMenu(sharedMenu);
//some container class
QPushButton *a,*b,*c;
//initialization code
QAction *superCoolAction; //action initialized to release some signal, SCA_Signal
QMenu *sharedMenu;
//initialization code contains superCoolAction, it's parent is this container class
a->addMenu(sharedMenu);
b->addMenu(sharedMenu);
c->addMenu(sharedMenu);
To copy to clipboard, switch view to plain text mode
Now, when someone clicks on any of these buttons it will open the menu; and they may click the action (which will emit SCA_Signal), but I'd like this signal to contain data telling me which button released it. Boiling this question down further, I'm curious if there's a "who called me" style function I can use on menus.
I ask because I know you can do this with Signals, but in that case it would just tell me the "menu" called it I believe. I've considered odd implementations such as releasing a signal when the button is clicked to "pre-empt" the next signal so I can bypass this issue; but that causes a coupling issue. I could instead prep the container class to catch SCA_Signal and clean it up, emiting a similar signal with the necessary information about who called it; but these both feel klugey.
What's the best way to know which button opened a menu if it's a menu that is used on several buttons?
Bookmarks