Qt-interest Archive, December 2006
QWidgetAction
Message 1 in thread
Has anyone here used QWidgetAction? I'd kill for an example. The Qt
docs with regard to this class are incredibly terse. :-(
--
[ signature omitted ]
Message 2 in thread
Hi,
Will Stokes wrote:
> Has anyone here used QWidgetAction? I'd kill for an example. The Qt
> docs with regard to this class are incredibly terse. :-(
>
You can use QWidgetAction for adding widgets into containers that
display actions (menus, toolbars and so on). So for instance, lets say
you want to have a push button or a label (nice for "headers") in a
menu. Just do this,
QWidgetAction *widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(new QPushButton("Cut and Paste"));
menu.addAction(widgetAction);
The default widget feature is useful only in the case where the
QWidgetAction is added to one action container. When the same
QWidgetAction is added to multiple action containers (into a toolbar AND
a menu, for instance) you need to subclass QWidgetAction and reimplement
createWidget() to provide a new widget.
Girish
--
[ signature omitted ]