|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QAction
com.trolltech.qt.gui.QWidgetAction
public class QWidgetAction
The QWidgetAction class extends QAction by an interface for inserting custom widgets into action based containers, such as toolbars.
Most actions in application are represented as items in menus or buttons in toolbars. However sometimes more complex widgets are necessary. For example a zoom action in a word processor may be realized using a QComboBox in a QToolBar, presenting a range of different zoom levels. QToolBar provides QToolBar::insertWidget() as convenience function for inserting a single widget. However if you want to implement an action that uses custom widgets for visualization in multiple containers then you have to subclass QWidgetAction.
If a QWidgetAction is added for example to a QToolBar then QWidgetAction::createWidget() is called. Reimplementations of that function should create a new custom widget with the specified parent.
If the action is removed from a container widget then QWidgetAction::deleteWidget() is called with the previously created custom widget as argument. The default implementation hides the widget and deletes it using QObject::deleteLater().
If you have only one single custom widget then you can set it as default widget using setDefaultWidget. That widget will then be used if the action is added to a QToolBar, or in general to an action container that supports QWidgetAction. If a QWidgetAction with only a default widget is added to two toolbars at the same time then the default widget is shown only in the first toolbar the action was added to. QWidgetAction takes over ownership of the default widget.
Note that it is up to the widget to activate the action, for example by reimplementing mouse event handlers and calling QAction::trigger().
Mac OS X: If you add widgets to a menu in the application's menu bar on Mac OS X, the widget will be added and function but there are some limitations:
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAction |
---|
QAction.ActionEvent, QAction.MenuRole |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.gui.QAction |
---|
changed, hovered, toggled, triggered |
Constructor Summary | |
---|---|
QWidgetAction(QObject parent)
Constructs an action with parent. |
Method Summary | |
---|---|
protected java.util.List<QWidget> |
createdWidgets()
Returns the list of widgets that have been using createWidget and are currently in use by widgets the action has been added to. |
protected QWidget |
createWidget(QWidget parent)
This function is called whenever the action is added to a container widget that supports custom widgets. |
QWidget |
defaultWidget()
Returns the default widget. |
protected void |
deleteWidget(QWidget widget)
This function is called whenever the action is removed from a container widget that displays the action using a custom widget previously created using createWidget. |
boolean |
event(QEvent arg__1)
This function is reimplemented for internal reasons. |
static QWidgetAction |
fromNativePointer(QNativePointer nativePointer)
This function returns the QWidgetAction instance pointed to by nativePointer |
void |
releaseWidget(QWidget widget)
Releases the specified widget. |
QWidget |
requestWidget(QWidget parent)
Returns a widget that represents the action, with the given parent. |
void |
setDefaultWidget(QWidget w)
Sets w to be the default widget. |
Methods inherited from class com.trolltech.qt.gui.QAction |
---|
actionGroup, activate, associatedWidgets, autoRepeat, data, font, hover, icon, iconText, isCheckable, isChecked, isEnabled, isSeparator, isVisible, menu, menuRole, parentWidget, setActionGroup, setAutoRepeat, setCheckable, setChecked, setData, setDisabled, setEnabled, setFont, setIcon, setIcon, setIconText, setMenu, setMenuRole, setSeparator, setShortcut, setShortcut, setShortcut, setShortcutContext, setShortcuts, setShortcuts, setStatusTip, setText, setToolTip, setVisible, setWhatsThis, shortcut, shortcutContext, shortcuts, showStatusText, showStatusText, statusTip, text, toggle, toolTip, trigger, whatsThis |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QWidgetAction(QObject parent)
Constructs an action with parent.
Method Detail |
---|
protected final java.util.List<QWidget> createdWidgets()
Returns the list of widgets that have been using createWidget and are currently in use by widgets the action has been added to.
public final QWidget defaultWidget()
Returns the default widget.
public final void releaseWidget(QWidget widget)
Releases the specified widget.
Container widgets that support actions call this function when a widget action is removed.
public final QWidget requestWidget(QWidget parent)
Returns a widget that represents the action, with the given parent.
Container widgets that support actions can call this function to request a widget as visual representation of the action.
public final void setDefaultWidget(QWidget w)
Sets w to be the default widget. The ownership is transferred to QWidgetAction. Unless createWidget is reimplemented by a subclass to return a new widget the default widget is used when a container widget requests a widget through requestWidget.
protected QWidget createWidget(QWidget parent)
This function is called whenever the action is added to a container widget that supports custom widgets. If you don't want a custom widget to be used as representation of the action in the specified parent widget then 0 should be returned.
protected void deleteWidget(QWidget widget)
This function is called whenever the action is removed from a container widget that displays the action using a custom widget previously created using createWidget. The default implementation hides the widget and schedules it for deletion using QObject::deleteLater().
public boolean event(QEvent arg__1)
This function is reimplemented for internal reasons.
event
in class QAction
public static QWidgetAction fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |