PDA

View Full Version : Actions and what to do with them?



krsmichael
20th January 2006, 21:45
The 4.1 designer lets you create actions. I can assign icons to the actions and then use them in the menu and toolbar. What does an action accomplish that a signal from a button, "clicked()" to a slot "handleClick()" doesn't do. The docs on QAction leave a lot to be desired. Does the action aid in the implementation of undo?

I guess I am trying to get a grasp of the intent of QAction and QActionGroup.

M

wysota
20th January 2006, 22:03
Actions are meant to be put into a menu or a toolbar. You can't put a single button to the toolbar and the menu. You can do (and actually do) it with an action. It's just easier to operate on it. Comparing an action to a signal emitted from a button is some kind of newbie thing :) actions emit signals and buttons emit signals. You connect "slots" to both of them, so they have exactly the same capabilities of invoking slots. The difference is that you put actions into toolbars and menus and buttons on the form.

jacek
20th January 2006, 22:08
Suppose you have a lot of menu items, yet not every user needs all of them and different users need different set of menu items. I bet you would allow your users to customize menus, but how?

You need a list of objects that describe all possible menu items. Such object would have to hold some text, an icon, tool tip, status tip, "What's this?" text, shortcut and some information about the method that must be called when the menu item is activated and so on.

Which class you should use in such situation?

PS. In fact there is no QMenuItem class in Qt 4 (except for Qt 3 Support module). Guess what class is there instead ;)