继承者: QGraphicsProxyWidget , QGraphicsWebView
PySide.QtGui.QGraphicsWidget class is the base class for all widget items in a PySide.QtGui.QGraphicsScene .
PySide.QtGui.QGraphicsWidget is an extended base item that provides extra functionality over PySide.QtGui.QGraphicsItem . It is similar to PySide.QtGui.QWidget in many ways:
不像 PySide.QtGui.QGraphicsItem , PySide.QtGui.QGraphicsWidget is not an abstract class; you can create instances of a PySide.QtGui.QGraphicsWidget without having to subclass it. This approach is useful for widgets that only serve the purpose of organizing child widgets into a layout.
PySide.QtGui.QGraphicsWidget can be used as a base item for your own custom item if you require advanced input focus handling, e.g., tab focus and activation, or layouts.
Since PySide.QtGui.QGraphicsWidget resembles PySide.QtGui.QWidget and has similar API, it is easier to port a widget from PySide.QtGui.QWidget to PySide.QtGui.QGraphicsWidget , instead of PySide.QtGui.QGraphicsItem .
注意
PySide.QtGui.QWidget -based widgets can be directly embedded into a PySide.QtGui.QGraphicsScene 使用 PySide.QtGui.QGraphicsProxyWidget .
Noticeable differences between PySide.QtGui.QGraphicsWidget and PySide.QtGui.QWidget 是:
| PySide.QtGui.QGraphicsWidget | PySide.QtGui.QWidget |
| Coordinates and geometry are defined with qreals (doubles or floats, depending on the platform). | PySide.QtGui.QWidget uses integer geometry ( PySide.QtCore.QPoint , PySide.QtCore.QRect ). |
| The widget is already visible by default; you do not have to call PySide.QtGui.QGraphicsItem.show() to display the widget. | PySide.QtGui.QWidget is hidden by default until you call PySide.QtGui.QGraphicsItem.show() . |
| A subset of widget attributes are supported. | All widget attributes are supported. |
| A top-level item's style defaults to QGraphicsScene::style | A top-level widget's style defaults to QApplication::style |
| Graphics View provides a custom drag and drop framework, different from PySide.QtGui.QWidget . | Standard drag and drop framework. |
| Widget items do not support modality. | Full modality support. |
PySide.QtGui.QGraphicsWidget supports a subset of Qt's widget attributes, ( Qt.WidgetAttribute ), as shown in the table below. Any attributes not listed in this table are unsupported, or otherwise unused.
| Widget Attribute | 用法 |
| Qt.WA_SetLayoutDirection | Set by PySide.QtGui.QGraphicsWidget.setLayoutDirection() , cleared by PySide.QtGui.QGraphicsWidget.unsetLayoutDirection() . You can test this attribute to check if the widget has been explicitly assigned a PySide.QtGui.QGraphicsWidget.layoutDirection() . If the attribute is not set, the PySide.QtGui.QGraphicsWidget.layoutDirection() is inherited. |
| Qt.WA_RightToLeft | Toggled by PySide.QtGui.QGraphicsWidget.setLayoutDirection() . Inherited from the parent/scene. If set, the widget's layout will order horizontally arranged widgets from right to left. |
| Qt.WA_SetStyle | Set and cleared by PySide.QtGui.QGraphicsWidget.setStyle() . If this attribute is set, the widget has been explicitly assigned a style. If it is unset, the widget will use the scene's or the application's style. |
| Qt.WA_Resized | Set by PySide.QtGui.QGraphicsWidget.setGeometry() and PySide.QtGui.QGraphicsWidget.resize() . |
| Qt.WA_SetPalette | Set by PySide.QtGui.QGraphicsWidget.setPalette() . |
| Qt.WA_SetFont | Set by PySide.QtGui.QGraphicsWidget.setFont() . |
| Qt.WA_WindowPropagation | Enables propagation to window widgets. |
尽管 PySide.QtGui.QGraphicsWidget inherits from both PySide.QtCore.QObject and PySide.QtGui.QGraphicsItem , you should use the functions provided by PySide.QtGui.QGraphicsItem , not PySide.QtCore.QObject , to manage the relationships between parent and child items. These functions control the stacking order of items as well as their ownership.
注意
QObject.parent() should always return 0 for QGraphicsWidgets, but this policy is not strictly defined.
另请参阅
PySide.QtGui.QGraphicsProxyWidget PySide.QtGui.QGraphicsItem Widget 和布局
| 参数: |
|
|---|
| 返回类型: |
|---|
返回此 Widget 的动作列表 (可能为空)。
| 参数: | action – PySide.QtGui.QAction |
|---|
追加动作 action 到此 Widget 的动作列表。
All QGraphicsWidgets have a list of PySide.QtGui.QAction ,无论如何,可以按多种不同方式图形表示它们。默认使用 PySide.QtGui.QAction 列表 (返回通过 PySide.QtGui.QGraphicsWidget.actions() ) is to create a context PySide.QtGui.QMenu .
A PySide.QtGui.QGraphicsWidget 只应每动作有一个,且已添加动作不会导致同一动作在 Widget 中出现两次。
| 参数: | actions – |
|---|
Adjusts the size of the widget to its effective preferred size hint.
This function is called implicitly when the item is shown for the first time.
另请参阅
PySide.QtGui.QGraphicsLayoutItem.effectiveSizeHint() Qt.MinimumSize
| 返回类型: | PySide.QtCore.bool |
|---|
This property holds whether the widget background is filled automatically.
If enabled, this property will cause Qt to fill the background of the widget before invoking the PySide.QtGui.QGraphicsWidget.paint() method. The color used is defined by the QPalette.Window 颜色角色来自 Widget 的 palette .
此外,填充窗口总是采用 QPalette.Window ,除非有设置 WA_OpaquePaintEvent 或 WA_NoSystemBackground 属性。
默认情况下,此特性为 false。
另请参阅
Qt.WA_OpaquePaintEvent Qt.WA_NoSystemBackground
| 参数: | event – PySide.QtCore.QEvent |
|---|
此事件处理程序可以被重实现以处理状态改变。
The state being changed in this event can be retrieved through event .
改变事件包括: QEvent.ActivationChange , QEvent.EnabledChange , QEvent.FontChange , QEvent.StyleChange , QEvent.PaletteChange , QEvent.ParentChange , QEvent.LayoutDirectionChange ,和 QEvent.ContentsRectChange .
| 返回类型: | PySide.QtCore.bool |
|---|
Call this function to close the widget.
Returns true if the widget was closed; otherwise returns false. This slot will first send a PySide.QtGui.QCloseEvent to the widget, which may or may not accept the event. If the event was ignored, nothing happens. If the event was accepted, it will PySide.QtGui.QGraphicsItem.hide() the widget.
若 Widget 拥有 Qt.WA_DeleteOnClose attribute set it will be deleted.
| 参数: | event – PySide.QtGui.QCloseEvent |
|---|
This event handler, for event , can be reimplemented in a subclass to receive widget close events. The default implementation accepts the event.
| 参数: | next – PySide.QtCore.bool |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget; returns false otherwise. If next is true, this function searches forward; if next 为 False,向后搜索。
Sometimes, you will want to reimplement this function to provide special focus handling for your widget and its subwidgets. For example, a web browser might reimplement it to move its current active link forward or backward, and call the base implementation only when it reaches the last or first link on the page.
Child widgets call PySide.QtGui.QGraphicsWidget.focusNextPrevChild() on their parent widgets, but only the window that contains the child widgets decides where to redirect focus. By reimplementing this function for an object, you gain control of focus traversal for all child widgets.
| 返回类型: | PySide.QtCore.Qt.FocusPolicy |
|---|
This property holds the way the widget accepts keyboard focus.
The focus policy is Qt.TabFocus 若 Widget 通过 Tab 键接受键盘聚焦, Qt.ClickFocus 若 Widget 通过点击接受聚焦, Qt.StrongFocus 若它接受两者,而 Qt.NoFocus (默认) 若它根本不接受聚焦。
必须为 Widget 启用键盘聚焦,若它处理键盘事件。通常这是由 Widget 的构造函数完成的。例如, PySide.QtGui.QLineEdit 构造函数调用 setFocusPolicy( Qt.StrongFocus ).
If you enable a focus policy (i.e., not Qt.NoFocus ), PySide.QtGui.QGraphicsWidget will automatically enable the ItemIsFocusable flag. Setting Qt.NoFocus on a widget will clear the ItemIsFocusable flag. If the widget currently has keyboard focus, the widget will automatically lose focus.
另请参阅
PySide.QtGui.QGraphicsWidget.focusInEvent() PySide.QtGui.QGraphicsWidget.focusOutEvent() PySide.QtGui.QGraphicsItem.keyPressEvent() PySide.QtGui.QGraphicsItem.keyReleaseEvent() enabled()
| 返回类型: | PySide.QtGui.QGraphicsWidget |
|---|
If this widget, a child or descendant of this widget currently has input focus, this function will return a pointer to that widget. If no descendant widget has input focus, 0 is returned.
| 返回类型: | PySide.QtGui.QFont |
|---|
This property holds the widgets' font.
This property provides the widget's font.
PySide.QtGui.QFont consists of font properties that have been explicitly defined and properties implicitly inherited from the widget's parent. Hence, PySide.QtGui.QGraphicsWidget.font() can return a different font compared to the one set with PySide.QtGui.QGraphicsWidget.setFont() . This scheme allows you to define single entries in a font without affecting the font's inherited entries.
When a widget's font changes, it resolves its entries against its parent widget. If the widget does not have a parent widget, it resolves its entries against the scene. The widget then sends itself a FontChange event and notifies all its descendants so that they can resolve their fonts as well.
默认情况下,此特性包含应用程序默认字体。
Gets the widget's window frame margins. The margins are stored in left , top , right and bottom as pointers to qreals. Each argument can be omitted by passing 0.
| 参数: | event – PySide.QtCore.QEvent |
|---|
This event handler, for event , can be reimplemented in a subclass to receive notifications for QEvent.GrabKeyboard 事件。
| 参数: | event – PySide.QtCore.QEvent |
|---|
This event handler, for event , can be reimplemented in a subclass to receive notifications for QEvent.GrabMouse 事件。
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.int |
| 参数: | event – PySide.QtGui.QHideEvent |
|---|
This event handler, for Hide events, is delivered after the widget has been hidden, for example, setVisible(false) has been called for the widget or one of its ancestors when the widget was previously shown.
You can reimplement this event handler to detect when your widget is hidden. Calling QEvent.accept() or QEvent.ignore() on event 不起作用。
另请参阅
PySide.QtGui.QGraphicsWidget.showEvent() QWidget.hideEvent() ItemVisibleChange
| 参数: | option – PySide.QtGui.QStyleOption |
|---|
Populates a style option object for this widget based on its current state, and stores the output in option . The default implementation populates option with the following properties.
| Style Option Property | 值 |
| state & QStyle.State_Enabled | Corresponds to QGraphicsItem.isEnabled() . |
| state & QStyle.State_HasFocus | Corresponds to QGraphicsItem.hasFocus() . |
| state & QStyle.State_MouseOver | Corresponds to QGraphicsItem.isUnderMouse() . |
| direction | Corresponds to QGraphicsWidget.layoutDirection() . |
| rect | Corresponds to QGraphicsWidget.rect() . toRect() . |
| palette | Corresponds to QGraphicsWidget.palette() . |
| fontMetrics | Corresponds to PySide.QtGui.QFontMetrics ( QGraphicsWidget.font() ). |
子类化的 PySide.QtGui.QGraphicsWidget should call the base implementation, and then test the type of option using qstyleoption_cast<>() or test QStyleOption.Type before storing widget-specific options.
例如:
class MyGroupBoxWidget (QStyleOptionGroupBox):
# ...
def initStyleOption(option):
QGraphicsWidget.initStyleOption(self, option)
if isinstance(option, QStyleOptionGroupBox):
# Add group box specific state.
box.flat = isFlat()
# ...
| 参数: |
|
|---|
插入动作 action 到此 Widget 的动作列表,前置于动作 before 。它追加动作,若 before is 0 or before 不是有效动作 (对于此 Widget)。
A PySide.QtGui.QGraphicsWidget 每动作只应有一个。
| 参数: |
|
|---|
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if this widget's window is in the active window, or if the widget does not have a window but is in an active scene (i.e., a scene that currently has focus).
The active window is the window that either contains a child widget that currently has input focus, or that itself has input focus.
| 返回类型: | PySide.QtGui.QGraphicsLayout |
|---|
This property holds The layout of the widget.
Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.
PySide.QtGui.QGraphicsWidget takes ownership of layout .
All widgets that are currently managed by layout or all of its sublayouts, are automatically reparented to this item. The layout is then invalidated, and the child widget geometries are adjusted according to this item's PySide.QtGui.QGraphicsLayoutItem.geometry() and contentsMargins(). Children who are not explicitly managed by layout remain unaffected by the layout after it has been assigned to this widget.
If no layout is currently managing this widget, PySide.QtGui.QGraphicsWidget.layout() will return 0.
| 返回类型: | PySide.QtCore.Qt.LayoutDirection |
|---|
This property holds the layout direction for this widget..
This property modifies this widget's and all of its descendants' Qt.WA_RightToLeft attribute. It also sets this widget's Qt.WA_SetLayoutDirection 属性。
The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt.LeftToRight , the layout starts placing subwidgets from the left side of this widget towards the right. Qt.RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.
Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling PySide.QtGui.QGraphicsWidget.setLayoutDirection() , the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.
| 参数: | event – PySide.QtGui.QGraphicsSceneMoveEvent |
|---|
This event handler, for GraphicsSceneMove events, is delivered after the widget has moved (e.g., its local position has changed).
This event is only delivered when the item is moved locally. Calling PySide.QtGui.QGraphicsItem.setTransform() or moving any of the item's ancestors does not affect the item's local position.
You can reimplement this event handler to detect when your widget has moved. Calling QEvent.accept() or QEvent.ignore() on event 不起作用。
另请参阅
ItemPositionChange ItemPositionHasChanged
| 参数: |
|
|---|
此虚拟函数被调用由 PySide.QtGui.QGraphicsScene to draw the window frame for windows using painter , option ,和 widget , in local coordinates. The base implementation uses the current style to render the frame and title bar.
You can reimplement this function in a subclass of PySide.QtGui.QGraphicsWidget to provide custom rendering of the widget's window frame.
| 返回类型: | PySide.QtGui.QPalette |
|---|
This property holds the widget's palette.
This property provides the widget's palette. The palette provides colors and brushes for color groups (e.g., QPalette.Button ) and states (e.g., QPalette.Inactive ), loosely defining the general look of the widget and its children.
PySide.QtGui.QPalette consists of color groups that have been explicitly defined, and groups that are implicitly inherited from the widget's parent. Because of this, PySide.QtGui.QGraphicsWidget.palette() can return a different palette than what has been set with PySide.QtGui.QGraphicsWidget.setPalette() . This scheme allows you to define single entries in a palette without affecting the palette's inherited entries.
When a widget's palette changes, it resolves its entries against its parent widget, or if it doesn't have a parent widget, it resolves against the scene. It then sends itself a PaletteChange event, and notifies all its descendants so they can resolve their palettes as well.
By default, this property contains the application's default palette.
This event is delivered to the item by the scene at some point after it has been constructed, but before it is shown or otherwise accessed through the scene. You can use this event handler to do last-minute initializations of the widget which require the item to be fully constructed.
The base implementation does nothing.
| 参数: |
|
|---|---|
| 返回类型: |
object |
This virtual function is used to notify changes to any property (both dynamic properties, and registered with Q_PROPERTY) in the widget. Depending on the property itself, the notification can be delivered before or after the value has changed.
propertyName is the name of the property (e.g., “size” or “font”), and value is the (proposed) new value of the property. The function returns the new value, which may be different from value if the notification supports adjusting the property value. The base implementation simply returns value for any propertyName .
PySide.QtGui.QGraphicsWidget delivers notifications for the following properties:
| PySide.QtGui.QGraphicsWidget.layoutDirection() | QGraphicsWidget.layoutDirection |
| size | QGraphicsWidget.size |
| font | QGraphicsWidget.font |
| palette | QGraphicsWidget.palette |
另请参阅
PySide.QtGui.QGraphicsWidget.itemChange()
| 返回类型: | PySide.QtCore.QRectF |
|---|
Returns the item's local rect as a PySide.QtCore.QRectF . This function is equivalent to PySide.QtCore.QRectF ( QPointF() , PySide.QtGui.QGraphicsWidget.size() ).
| 参数: | id – PySide.QtCore.int |
|---|
删除快捷方式采用给定 id 从 Qt 的快捷方式系统。Widget 将不再接收 QEvent.Shortcut events for the shortcut's key sequence (unless it has other shortcuts with the same key sequence).
警告
You should not normally need to use this function since Qt's shortcut system removes shortcuts automatically when their parent widget is destroyed. It is best to use PySide.QtGui.QAction or PySide.QtGui.QShortcut to handle shortcuts, since they are easier to use than this low-level function. Note also that this is an expensive operation.
| 参数: | action – PySide.QtGui.QAction |
|---|
移除动作 action 从此 Widget 的动作列表。
| 参数: | size – PySide.QtCore.QSizeF |
|---|
This property holds the size of the widget.
调用 PySide.QtGui.QGraphicsWidget.resize() resizes the widget to a size bounded by PySide.QtGui.QGraphicsLayoutItem.minimumSize() and PySide.QtGui.QGraphicsLayoutItem.maximumSize() . This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.
Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.
This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout; e.g., it has a parent widget with a layout assigned, that layout will not activate.
By default, this property contains a size with zero width and height.
| 参数: |
|
|---|
This convenience function is equivalent to calling resize( PySide.QtCore.QSizeF (w, h)).
| 参数: | event – PySide.QtGui.QGraphicsSceneResizeEvent |
|---|
This event handler, for GraphicsSceneResize events, is delivered after the widget has been resized (i.e., its local size has changed). event contains both the old and the new size.
This event is only delivered when the widget is resized locally; calling PySide.QtGui.QGraphicsItem.setTransform() on the widget or any of its ancestors or view, does not affect the widget's local size.
You can reimplement this event handler to detect when your widget has been resized. Calling QEvent.accept() or QEvent.ignore() on event 不起作用。
| 参数: |
|
|---|
| 参数: | enabled – PySide.QtCore.bool |
|---|
This property holds whether the widget background is filled automatically.
If enabled, this property will cause Qt to fill the background of the widget before invoking the PySide.QtGui.QGraphicsWidget.paint() method. The color used is defined by the QPalette.Window 颜色角色来自 Widget 的 palette .
此外,填充窗口总是采用 QPalette.Window ,除非有设置 WA_OpaquePaintEvent 或 WA_NoSystemBackground 属性。
默认情况下,此特性为 false。
另请参阅
Qt.WA_OpaquePaintEvent Qt.WA_NoSystemBackground
| 参数: |
|
|---|
Sets the widget's contents margins to left , top , right and bottom .
Contents margins are used by the assigned layout to define the placement of subwidgets and layouts. Margins are particularly useful for widgets that constrain subwidgets to only a section of its own geometry. For example, a group box with a layout will place subwidgets inside its frame, but below the title.
Changing a widget's contents margins will always trigger an PySide.QtGui.QGraphicsItem.update() , and any assigned layout will be activated automatically. The widget will then receive a ContentsRectChange 事件。
另请参阅
PySide.QtGui.QGraphicsWidget.getContentsMargins() PySide.QtGui.QGraphicsWidget.setGeometry()
| 参数: | policy – PySide.QtCore.Qt.FocusPolicy |
|---|
This property holds the way the widget accepts keyboard focus.
The focus policy is Qt.TabFocus 若 Widget 通过 Tab 键接受键盘聚焦, Qt.ClickFocus 若 Widget 通过点击接受聚焦, Qt.StrongFocus 若它接受两者,而 Qt.NoFocus (默认) 若它根本不接受聚焦。
必须为 Widget 启用键盘聚焦,若它处理键盘事件。通常这是由 Widget 的构造函数完成的。例如, PySide.QtGui.QLineEdit 构造函数调用 setFocusPolicy( Qt.StrongFocus ).
If you enable a focus policy (i.e., not Qt.NoFocus ), PySide.QtGui.QGraphicsWidget will automatically enable the ItemIsFocusable flag. Setting Qt.NoFocus on a widget will clear the ItemIsFocusable flag. If the widget currently has keyboard focus, the widget will automatically lose focus.
另请参阅
PySide.QtGui.QGraphicsWidget.focusInEvent() PySide.QtGui.QGraphicsWidget.focusOutEvent() PySide.QtGui.QGraphicsItem.keyPressEvent() PySide.QtGui.QGraphicsItem.keyReleaseEvent() enabled()
| 参数: | font – PySide.QtGui.QFont |
|---|
This property holds the widgets' font.
This property provides the widget's font.
PySide.QtGui.QFont consists of font properties that have been explicitly defined and properties implicitly inherited from the widget's parent. Hence, PySide.QtGui.QGraphicsWidget.font() can return a different font compared to the one set with PySide.QtGui.QGraphicsWidget.setFont() . This scheme allows you to define single entries in a font without affecting the font's inherited entries.
When a widget's font changes, it resolves its entries against its parent widget. If the widget does not have a parent widget, it resolves its entries against the scene. The widget then sends itself a FontChange event and notifies all its descendants so that they can resolve their fonts as well.
默认情况下,此特性包含应用程序默认字体。
| 参数: |
|
|---|
This convenience function is equivalent to calling setGeometry( PySide.QtCore.QRectF ( x , y , w , h )).
| 参数: | layout – PySide.QtGui.QGraphicsLayout |
|---|
This property holds The layout of the widget.
Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.
PySide.QtGui.QGraphicsWidget takes ownership of layout .
All widgets that are currently managed by layout or all of its sublayouts, are automatically reparented to this item. The layout is then invalidated, and the child widget geometries are adjusted according to this item's PySide.QtGui.QGraphicsLayoutItem.geometry() and contentsMargins(). Children who are not explicitly managed by layout remain unaffected by the layout after it has been assigned to this widget.
If no layout is currently managing this widget, PySide.QtGui.QGraphicsWidget.layout() will return 0.
| 参数: | direction – PySide.QtCore.Qt.LayoutDirection |
|---|
This property holds the layout direction for this widget..
This property modifies this widget's and all of its descendants' Qt.WA_RightToLeft attribute. It also sets this widget's Qt.WA_SetLayoutDirection 属性。
The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt.LeftToRight , the layout starts placing subwidgets from the left side of this widget towards the right. Qt.RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.
Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling PySide.QtGui.QGraphicsWidget.setLayoutDirection() , the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.
| 参数: | palette – PySide.QtGui.QPalette |
|---|
This property holds the widget's palette.
This property provides the widget's palette. The palette provides colors and brushes for color groups (e.g., QPalette.Button ) and states (e.g., QPalette.Inactive ), loosely defining the general look of the widget and its children.
PySide.QtGui.QPalette consists of color groups that have been explicitly defined, and groups that are implicitly inherited from the widget's parent. Because of this, PySide.QtGui.QGraphicsWidget.palette() can return a different palette than what has been set with PySide.QtGui.QGraphicsWidget.setPalette() . This scheme allows you to define single entries in a palette without affecting the palette's inherited entries.
When a widget's palette changes, it resolves its entries against its parent widget, or if it doesn't have a parent widget, it resolves against the scene. It then sends itself a PaletteChange event, and notifies all its descendants so they can resolve their palettes as well.
By default, this property contains the application's default palette.
| 参数: |
|
|---|
若 enabled is true, auto repeat of the shortcut with the given id 被启用;否则它被禁用。
| 参数: |
|
|---|
若 enabled 为 True,快捷方式采用给定 id 被启用;否则快捷方式被禁用。
警告
You should not normally need to use this function since Qt's shortcut system enables/disables shortcuts automatically as widgets become hidden/visible and gain or lose focus. It is best to use PySide.QtGui.QAction or PySide.QtGui.QShortcut to handle shortcuts, since they are easier to use than this low-level function.
| 参数: | style – PySide.QtGui.QStyle |
|---|
Sets the widget's style to style . PySide.QtGui.QGraphicsWidget does not take ownership of style .
If no style is assigned, or style is 0, the widget will use QGraphicsScene.style() (if this has been set). Otherwise the widget will use QApplication.style() .
此函数设置 Qt.WA_SetStyle attribute if style is not 0; otherwise it clears the attribute.
| 参数: |
|
|---|
Moves the second widget around the ring of focus widgets so that keyboard focus moves from the first widget to the second widget when the Tab key is pressed.
Note that since the tab order of the second widget is changed, you should order a chain like this:
setTabOrder(a, b) # a to b
setTabOrder(b, c) # a to b to c
setTabOrder(c, d) # a to b to c to d
not 像这样:
# WRONG
setTabOrder(c, d) # c to d
setTabOrder(a, b) # a to b AND c to d
setTabOrder(b, c) # a to b to c, but not c to d
若 first is 0, this indicates that second should be the first widget to receive input focus should the scene gain Tab focus (i.e., the user hits Tab so that focus passes into the scene). If second is 0, this indicates that first should be the first widget to gain focus if the scene gained BackTab focus.
By default, tab order is defined implicitly using widget creation order.
另请参阅
PySide.QtGui.QGraphicsWidget.focusPolicy() Keyboard Focus
| 参数: | wFlags – PySide.QtCore.Qt.WindowFlags |
|---|
This property holds the widget's window flags.
Window flags are a combination of a window type (e.g., Qt.Dialog ) and several flags giving hints on the behavior of the window. The behavior is platform-dependent.
By default, this property contains no window flags.
Windows are panels. If you set the Qt.Window flag, the ItemIsPanel flag will be set automatically. If you clear the Qt.Window flag, the ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be set independently of Qt.Window .
| 参数: |
|
|---|
Sets the widget's window frame margins to left , top , right and bottom . The default frame margins are provided by the style, and they depend on the current window flags.
If you would like to draw your own window decoration, you can set your own frame margins to override the default margins.
| 参数: | title – unicode |
|---|
This property holds This property holds the window title (caption)..
This property is only used for windows.
By default, if no title has been set, this property contains an empty string.
| 参数: | event – PySide.QtGui.QShowEvent |
|---|
This event handler, for Show events, is delivered before the widget has been shown, for example, setVisible(true) has been called for the widget or one of its ancestors when the widget was previously hidden.
You can reimplement this event handler to detect when your widget is shown. Calling QEvent.accept() or QEvent.ignore() on event 不起作用。
另请参阅
PySide.QtGui.QGraphicsWidget.hideEvent() QWidget.showEvent() ItemVisibleChange
| 返回类型: | PySide.QtCore.QSizeF |
|---|
This property holds the size of the widget.
调用 PySide.QtGui.QGraphicsWidget.resize() resizes the widget to a size bounded by PySide.QtGui.QGraphicsLayoutItem.minimumSize() and PySide.QtGui.QGraphicsLayoutItem.maximumSize() . This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.
Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.
This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout; e.g., it has a parent widget with a layout assigned, that layout will not activate.
By default, this property contains a size with zero width and height.
| 返回类型: | PySide.QtGui.QStyle |
|---|
Returns a pointer to the widget's style. If this widget does not have any explicitly assigned style, the scene's style is returned instead. In turn, if the scene does not have any assigned style, this function returns QApplication.style() .
| 参数: | attribute – PySide.QtCore.Qt.WidgetAttribute |
|---|---|
| 返回类型: | PySide.QtCore.bool |
| 参数: | event – PySide.QtCore.QEvent |
|---|
This event handler, for event , can be reimplemented in a subclass to receive notifications for QEvent.UngrabKeyboard 事件。
| 参数: | event – PySide.QtCore.QEvent |
|---|
This event handler, for event , can be reimplemented in a subclass to receive notifications for QEvent.UngrabMouse 事件。
This property holds the layout direction for this widget..
This property modifies this widget's and all of its descendants' Qt.WA_RightToLeft attribute. It also sets this widget's Qt.WA_SetLayoutDirection 属性。
The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt.LeftToRight , the layout starts placing subwidgets from the left side of this widget towards the right. Qt.RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.
Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling PySide.QtGui.QGraphicsWidget.setLayoutDirection() , the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.
Resets the window frame margins to the default value, provided by the style.
| 返回类型: | PySide.QtCore.Qt.WindowFlags |
|---|
This property holds the widget's window flags.
Window flags are a combination of a window type (e.g., Qt.Dialog ) and several flags giving hints on the behavior of the window. The behavior is platform-dependent.
By default, this property contains no window flags.
Windows are panels. If you set the Qt.Window flag, the ItemIsPanel flag will be set automatically. If you clear the Qt.Window flag, the ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be set independently of Qt.Window .
| 参数: | e – PySide.QtCore.QEvent |
|---|---|
| 返回类型: | PySide.QtCore.bool |
This event handler, for event , receives events for the window frame if this widget is a window. Its base implementation provides support for default window frame interaction such as moving, resizing, etc.
You can reimplement this handler in a subclass of PySide.QtGui.QGraphicsWidget to provide your own custom window frame interaction support.
返回 true 若 event has been recognized and processed; otherwise, returns false.
另请参阅
PySide.QtGui.QGraphicsWidget.event()
| 返回类型: | PySide.QtCore.QRectF |
|---|
Returns the widget's geometry in parent coordinates including any window frame.
| 返回类型: | PySide.QtCore.QRectF |
|---|
Returns the widget's local rect including any window frame.
| 参数: | pos – PySide.QtCore.QPointF |
|---|---|
| 返回类型: | PySide.QtCore.Qt.WindowFrameSection |
Returns the window frame section at position pos ,或 Qt.NoSection if there is no window frame section at this position.
This function is used in PySide.QtGui.QGraphicsWidget ‘s base implementation for window frame interaction.
You can reimplement this function if you want to customize how a window can be interactively moved or resized. For instance, if you only want to allow a window to be resized by the bottom right corner, you can reimplement this function to return Qt.NoSection for all sections except Qt.BottomRightSection .
| 返回类型: | unicode |
|---|
This property holds This property holds the window title (caption)..
This property is only used for windows.
By default, if no title has been set, this property contains an empty string.
| 返回类型: | PySide.QtCore.Qt.WindowType |
|---|
Returns the widgets window type.