PDA

View Full Version : How to deal with shorcouts in many widgets



kazibi
29th January 2010, 09:20
How can I share the same shorcout between widgets?

I'm adding all the QActions I have to the applications main window widget, more precisely im adding Cut, Copy, and Paste actions. I have a QTabWidget as main window central widget. So I want to be able to use my actions in all my QTabWidget childs (the tabs), for example, i'm creating a custom texteditor, inheriting only from QWidget, how do I implement my editions(cut, copy..) actions?.

I have tried sharing the same actions objects between all the widgets, connecting them to my widget slots, but then, when I press the action shourcut, all the widgets get the event at the same time. I tried also overrading keyPressEvent in child widgets, but for some reason the shourcout events never trigers that slot, probably because the QAction created in the main window intercept them.


I can only think on one solution, handling all my logic at one place (in the main window), but it seems unatural.

Thank you.

aamer4yu
29th January 2010, 09:58
May be you can use QAction::triggered to connect to your child widgets :rolleyes: