PDA

View Full Version : WidgetWithChildrenShortcut not working?



mwoehlke
28th April 2011, 01:22
I'm trying to set up shortcuts for some actions in a context menu for a widget I have several instances of. This means that each widget is going to have the same (duplicate, actually) actions and same shortcuts, and the action should apply to the widget that has focus, so WindowShortcut is out.

Since the widget is a compound widget with a .ui (and I am hoping to define the actions in the .ui), I'm really hoping to be able to use WidgetWithChildrenShortcut rather than just WidgetShortcut, but for the life of me I can't get it to work.

Example .ui attached. Now, as far as I know, the action is owned by the QMainWindow, which means that WindowShortcut and WidgetWithChildrenShortcut should be effectively equivalent in this case, but I can't trigger the action by shortcut.

Anyone know what I am doing wrong?

I am using qt-4.7.2-8.fc14.x86_64

polto2010
28th April 2011, 02:29
i will check it

mwoehlke
28th April 2011, 02:53
So... interestingly, polto2010 (thanks for the help :)) says the .ui example works on OS-X.

Anyway, I think I finally figured it out. It seems that the widget for which the action will be triggered if that widget or its children have focus is NOT the parent of the QAction, but any (and all?) widget(s) to which the action has been added by QWidget::addAction.

IOW this might never work as a pure-.ui example... BUT I can get it working in my application.