Apparently separator will always fill the height of the toolbar (or width for vertical toolbars). You can limit it by adding top/bottom margins, so if your toolbar is 40px and you want the separator to be 30px add 5px top and bottom margins.
Because we had declarations of shortcuts littered all over the place we came up with the following solution to handle them in one place.
We derived a class MyApplication from QApplication and overrode bool notify(QObject *receiver, QEvent *e) override. Within this function we checked e->type() == QEvent::Shortcut. Everything that couldn't be handled is then forwarded to QApplication::notify.
We didn't override the Ctrl+C shortcut or anything similar. However, because this is so early in Qt's signal handling you could be lucky with this approach.
Why do you need to know the parent?
QAction can be shared so the same function can be activated from
multiple sources. But normally action does the same regardless from where is was triggered.
I need to adjust action command parameters depending on the parent widget.
I tried action->parentWidget() but it did not return anything I could use .
Esentially I can have action that does A+B, and if the action is in global widget it would do just that, but if its in local widget then I will need localA + localB... more or less... thus the need to have a way to knowing parent widget while sending command to work.
Instead of starting with the action you can connect to the menu's triggered signal. In the slot sender() will give you the menu and you can go up the parents with parentWidget() to find the toolbar if you need.
Hmmmmm that looks very tempting!!! Will give it a go thanks!
I was about to write my own action system to handle my needs but perhaps with Chris Kawa reply I can utilize native qt ones ! Thanks!
Ok so this gets me half way there. I can now do quite a bit nice stuff with menu & actions, like changing menu default action to do something else based on action clicked and all that - yay !
But... how do I find out that menu parent - QToolbar or QToolButton? Is there a path down from there?
And it looks like the toolButton has thesame triggered signal... hmmmm
yep this is beautifull, it propagates all the way to toolButton where I can do what I want with the action and its data.