PythonQt.QtGui.QWidgetAction
QWidgetAction
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
Most actions in an 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().
macOS: If you add a widget to a menu in the application's menu bar on macOS, the widget will be added and it will function but with some limitations:
- The widget is reparented away from the QMenu to the native menu view. If you show the menu in some other place (e.g. as a popup menu), the widget will not be there.
- Focus/Keyboard handling of the widget is not possible.
- Due to Apple's design, mouse tracking on the widget currently does not work.
- Connecting the triggered() signal to a slot that opens a modal dialog will cause a crash in macOS 10.4 (known bug acknowledged by Apple), a workaround is to use a QueuedConnection instead of a DirectConnection.
Source: https://doc.qt.io/archives/qt-5.15/qwidgetaction.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
AboutQtRole |
attribute | Any |
(shared captured text) |
AboutRole |
attribute | Any |
(shared captured text) |
ActionEvent |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
ApplicationSpecificRole |
attribute | Any |
(shared captured text) |
HighPriority |
attribute | Any |
(shared captured text) |
Hover |
attribute | Any |
(shared captured text) |
LowPriority |
attribute | Any |
(shared captured text) |
MenuRole |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
NoRole |
attribute | Any |
(shared captured text) |
NormalPriority |
attribute | Any |
(shared captured text) |
PreferencesRole |
attribute | Any |
(shared captured text) |
Priority |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
QuitRole |
attribute | Any |
(shared captured text) |
TextHeuristicRole |
attribute | Any |
(shared captured text) |
Trigger |
attribute | Any |
(shared captured text) |
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
actionGroup |
function | (self) -> Any |
X.actionGroup() -> PythonQt.QtGui.QActionGroup |
activate |
function | (self, event: Any) -> Any |
|
associatedGraphicsWidgets |
function | (self) -> tuple |
X.associatedGraphicsWidgets() -> tuple |
associatedWidgets |
function | (self) -> tuple |
X.associatedWidgets() -> tuple |
autoRepeat |
attribute | Any |
(shared captured text) |
blockSignals |
function | (self, b: Any) -> bool |
X.blockSignals(b) -> bool (shared captured text) |
changed |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtGui.QWidgetAction.changed; argument details are not documented. |
checkable |
attribute | Any |
(shared captured text) |
checked |
attribute | Any |
(shared captured text) |
childEvent |
function | (self, event: Any) -> Any |
(shared captured text) |
children |
function | (self) -> tuple |
X.children() -> tuple (shared captured text) |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
connect |
function | (self, signal: Any, receiver: Any, slot: Any, type: Any) -> bool |
X.connect(signal, receiver, slot, type) -> bool (shared captured text) |
createWidget |
function | (self, parent: Any) -> Any |
X.createWidget(parent) -> PythonQt.QtGui.QWidget |
createdWidgets |
function | (self) -> tuple |
X.createdWidgets() -> tuple |
customEvent |
function | (self, event: Any) -> Any |
(shared captured text) |
data |
function | (self) -> Any |
X.data() -> object |
defaultWidget |
function | (self) -> Any |
X.defaultWidget() -> PythonQt.QtGui.QWidget |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
deleteLater |
function | (self) -> Any |
(shared captured text) |
deleteWidget |
function | (self, widget: Any) -> None |
This function is called whenever the action is removed from a container widget that displays the action using a custom widget previously created using… |
destroyed |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtGui.QWidgetAction.destroyed; argument details are not documented. |
disconnect |
function | (self, signal: Any, receiver: Any, slot: Any) -> bool |
X.disconnect(signal, receiver, slot) -> bool (shared captured text) |
dumpObjectInfo |
function | (self) -> Any |
(shared captured text) |
dumpObjectTree |
function | (self) -> Any |
(shared captured text) |
dynamicPropertyNames |
function | (self) -> Any |
(shared captured text) |
enabled |
attribute | Any |
(shared captured text) |
event |
function | (self, arg__1: Any) -> bool |
X.event(arg__1) -> bool |
eventFilter |
function | (self, arg__1: Any, arg__2: Any) -> bool |
X.eventFilter(arg__1, arg__2) -> bool |
findChild |
function | (self, type: Any, name: Any) -> Any |
X.findChild(type, name) -> PythonQt.private.QObject (shared captured text) |
findChildren |
function | (self, type: Any, name: Any) -> tuple |
X.findChildren(type, name) -> tuple (shared captured text) |
font |
attribute | QFont |
(shared captured text) |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
hover |
function | (self) -> Any |
|
hovered |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtGui.QWidgetAction.hovered; argument details are not documented. |
icon |
attribute | QIcon |
(shared captured text) |
iconText |
attribute | Any |
|
iconVisibleInMenu |
attribute | Any |
|
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
installEventFilter |
function | (self, filterObj: Any) -> Any |
(shared captured text) |
isCheckable |
function | (self) -> bool |
X.isCheckable() -> bool (shared captured text) |
isChecked |
function | (self) -> bool |
X.isChecked() -> bool (shared captured text) |
isEnabled |
function | (self) -> bool |
X.isEnabled() -> bool (shared captured text) |
isIconVisibleInMenu |
function | (self) -> bool |
X.isIconVisibleInMenu() -> bool |
isSeparator |
function | (self) -> bool |
X.isSeparator() -> bool |
isSignalConnected |
function | (self, signal: Any) -> bool |
X.isSignalConnected(signal) -> bool (shared captured text) |
isVisible |
function | (self) -> bool |
X.isVisible() -> bool (shared captured text) |
isWidgetType |
function | (self) -> bool |
X.isWidgetType() -> bool (shared captured text) |
isWindowType |
function | (self) -> bool |
X.isWindowType() -> bool (shared captured text) |
killTimer |
function | (self, id: Any) -> Any |
(shared captured text) |
menu |
function | (self) -> Any |
X.menu() -> PythonQt.QtGui.QMenu (shared captured text) |
menuRole |
attribute | Any |
|
metaObject |
function | (self) -> Any |
X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text) |
moveToThread |
function | (self, thread: Any) -> Any |
(shared captured text) |
objectName |
attribute | Any |
(shared captured text) |
objectNameChanged |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtGui.QWidgetAction.objectNameChanged; argument details are not documented. |
parent |
function | (self) -> Any |
X.parent() -> PythonQt.private.QObject (shared captured text) |
parentWidget |
function | (self) -> Any |
X.parentWidget() -> PythonQt.QtGui.QWidget (shared captured text) |
priority |
attribute | Any |
|
property |
function | (self, name: Any) -> Any |
X.property(name) -> object (shared captured text) |
releaseWidget |
function | (self, widget: Any) -> None |
Releases the specified widget. |
removeEventFilter |
function | (self, obj: Any) -> Any |
(shared captured text) |
requestWidget |
function | (self, parent: Any) -> Any |
X.requestWidget(parent) -> PythonQt.QtGui.QWidget |
sender |
function | (self) -> Any |
X.sender() -> PythonQt.private.QObject (shared captured text) |
senderSignalIndex |
function | (self) -> int |
X.senderSignalIndex() -> int (shared captured text) |
setActionGroup |
function | (self, group: Any) -> Any |
|
setAutoRepeat |
function | (self, arg__1: Any) -> Any |
(shared captured text) |
setCheckable |
function | (self, arg__1: Any) -> Any |
(shared captured text) |
setChecked |
function | (self, a: Any) -> Any |
(shared captured text) |
setData |
function | (self, var: Any) -> Any |
|
setDefaultWidget |
function | (self, w: Any) -> None |
Sets widget to be the default widget. |
setDisabled |
function | (self, b: Any) -> Any |
|
setEnabled |
function | (self, a: Any) -> Any |
(shared captured text) |
setFont |
function | (self, font: Any) -> Any |
(shared captured text) |
setIcon |
function | (self, icon: Any) -> Any |
(shared captured text) |
setIconText |
function | (self, text: Any) -> Any |
|
setIconVisibleInMenu |
function | (self, visible: Any) -> Any |
|
setMenu |
function | (self, menu: Any) -> Any |
(shared captured text) |
setMenuRole |
function | (self, menuRole: Any) -> Any |
|
setObjectName |
function | (self, name: Any) -> Any |
(shared captured text) |
setParent |
function | (self, parent: Any) -> Any |
(shared captured text) |
setPriority |
function | (self, priority: Any) -> Any |
|
setProperty |
function | (self, name: Any, value: Any) -> bool |
X.setProperty(name, value) -> bool (shared captured text) |
setSeparator |
function | (self, b: Any) -> Any |
|
setShortcut |
function | (self, shortcut: Any) -> Any |
|
setShortcutContext |
function | (self, context: Any) -> Any |
|
setShortcuts |
function | (self, arg__1: Any) -> Any |
|
setStatusTip |
function | (self, statusTip: Any) -> Any |
|
setText |
function | (self, text: Any) -> Any |
(shared captured text) |
setToolTip |
function | (self, tip: Any) -> Any |
(shared captured text) |
setVisible |
function | (self, a: Any) -> Any |
|
setWhatsThis |
function | (self, what: Any) -> Any |
|
shortcut |
attribute | QKeySequence |
(shared captured text) |
shortcutContext |
attribute | Any |
|
shortcutVisibleInContextMenu |
attribute | Any |
|
shortcuts |
function | (self) -> tuple |
X.shortcuts() -> tuple |
showStatusText |
function | (self, widget: Any) -> bool |
X.showStatusText(widget) -> bool |
signalsBlocked |
function | (self) -> bool |
X.signalsBlocked() -> bool (shared captured text) |
startTimer |
function | (self, interval: Any, timerType: Any) -> int |
X.startTimer(interval, timerType) -> int (shared captured text) |
statusTip |
attribute | Any |
(shared captured text) |
text |
attribute | Any |
(shared captured text) |
thread |
function | (self) -> Any |
(shared captured text) |
timerEvent |
function | (self, event: Any) -> Any |
(shared captured text) |
toggle |
function | (self) -> Any |
(shared captured text) |
toggled |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtGui.QWidgetAction.toggled; argument details are not documented. |
toolTip |
attribute | Any |
(shared captured text) |
tr |
function | (self, text: Any, ambig: Any, n: Any) -> str |
X.tr(text, ambig, n) -> str (shared captured text) |
trigger |
function | (self) -> Any |
|
triggered |
function | (self, *args: Any, **kwargs: Any) -> Any |
Native PythonQt.QtGui.QWidgetAction.triggered; argument details are not documented. |
visible |
attribute | Any |
(shared captured text) |
whatsThis |
attribute | Any |
(shared captured text) |