[Qt-interest] Porting Qt 3 to Qt 4
Jake Colman
colman at ppllc.com
Fri Sep 17 14:18:57 CEST 2010
>>>>> "SAB" == Scott Aron Bloom <Scott.Bloom at onshorecs.com> writes:
SAB> The QAction is much simpler to use.. In general, you can create
SAB> them two ways..
SAB> First, you can create them on the heap and store the pointer for
SAB> later. You are then responsible for the memory (which you can
SAB> always use the Qt parent/child relationship to handle)
SAB> You then call addAction( QAction * ) on any QWidget. QMenu and
SAB> QToolBar have special addAction methods, however, if the action
SAB> has a keyboard shortcut, and its on a widget, it will get
SAB> triggered when the keyboard shortcut is typed.
SAB> For any given action, you can have shortcuts, icons, hover text,
SAB> checkable , checked, you then also connect to the QActions
SAB> triggered signal to execute the slot.
SAB> You can assign the SAME action to multiple containers. For
SAB> instance, you can create the action, have it owned by the main
SAB> window, then add it to a tool bar and a menu of that main
SAB> window.. You might also add it to a context menu.
SAB> The great part, is you only need to set it to "checked" once, or
SAB> add its icon once.
SAB> Another option, that I usually only use in transient actions on
SAB> context menus, is to use the addAction( QString ) which creates
SAB> a QAction with the container as the parent. You should NOT add
SAB> these actions to another container widget.
SAB> So your notion of finding it, isn't necessary, since now you
SAB> simply store a pointer to it.
SAB> As to the Checkbox vs the Check mark, look at the QStyleSHeet
SAB> classes to set them on the QMenu item you have
Scott,
Thanks, that was very helpful. Please see my new posting regarding the
QStyleSheet. Perhaps you can help with that too.
--
Jake Colman | Director, Software Development
Principia Partners LLC
101 West Elm Street | Conshohocken | PA 19428 | +1 (610) 755 9770
t: +1 (610) 755 9786 | c: +1 (610) 348 2788 | f: +1 (201) 221 8929
e: colman at ppllc.com | w: www.principiapartners.com
Credit technology innovation awards winner 2008 and 2009
More information about the Qt-interest-old
mailing list