QGraphicsItem::GraphicsItemFlag setFlag setFlags

以下摘自qt帮助文档,版本归qt,不归笔者,仅供学习记录用。

qt QGraphicsItem中的setFlag主要有以下的flag。

enum QGraphicsItem::GraphicsItemFlag
flags QGraphicsItem::GraphicsItemFlags

This enum describes different flags that you can set on an item to toggle different features in the item's behavior.

All flags are disabled by default.

 

Constant

Value

Description

QGraphicsItem::ItemIsMovable

0x1

The item supports interactive movement using the mouse. By clicking on the item and then dragging, the item will move together with the mouse cursor. If the item has children, all children are also moved. If the item is part of a selection, all selected items are also moved. This feature is provided as a convenience through the base implementation of QGraphicsItem's mouse event handlers.

QGraphicsItem::ItemIsSelectable

0x2

The item supports selection. Enabling this feature will enable setSelected() to toggle selection for the item. It will also let the item be selected automatically as a result of calling QGraphicsScene::setSelectionArea(), by clicking on an item, or by using rubber band selection in QGraphicsView.

QGraphicsItem::ItemIsFocusable

0x4

The item supports keyboard input focus (i.e., it is an input item). Enabling this flag will allow the item to accept focus, which again allows the delivery of key events to QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent().

QGraphicsItem::ItemClipsToShape

0x8

The item clips to its own shape. The item cannot draw or receive mouse, tablet, drag and drop or hover events outside its shape. It is disabled by default. This behavior is enforced by QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3.

QGraphicsItem::ItemClipsChildrenToShape

0x10

The item clips the painting of all its descendants to its own shape. Items that are either direct or indirect children of this item cannot draw outside this item's shape. By default, this flag is disabled; children can draw anywhere. This behavior is enforced by QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3.

Note: This flag is similar to ItemContainsChildrenInShape but in addition enforces the containment by clipping the children.

 

Constant

Value

Description

QGraphicsItem::ItemIgnoresTransformations

0x20

The item ignores inherited transformations (i.e., its position is still anchored to its parent, but the parent or view rotation, zoom or shear transformations are ignored). This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed. When set, the item's view geometry and scene geometry will be maintained separately. You must call deviceTransform() to map coordinates and detect collisions in the view. By default, this flag is disabled. This flag was introduced in Qt 4.3.

Note: With this flag set you can still scale the item itself, and that scale transformation will influence the item's children.

 

Constant

Value

Description

QGraphicsItem::ItemIgnoresParentOpacity

0x40

The item ignores its parent's opacity. The item's effective opacity is the same as its own; it does not combine with the parent's opacity. This flags allows your item to keep its absolute opacity even if the parent is semitransparent. This flag was introduced in Qt 4.5.

QGraphicsItem::ItemDoesntPropagateOpacityToChildren

0x80

The item doesn't propagate its opacity to its children. This flag allows you to create a semitransparent item that does not affect the opacity of its children. This flag was introduced in Qt 4.5.

QGraphicsItem::ItemStacksBehindParent

0x100

The item is stacked behind its parent. By default, child items are stacked on top of the parent item. But setting this flag, the child will be stacked behind it. This flag is useful for drop shadow effects and for decoration objects that follow the parent item's geometry without drawing on top of it. This flag was introduced in Qt 4.5.

QGraphicsItem::ItemUsesExtendedStyleOption

0x200

The item makes use of either exposedRect or matrix in QStyleOptionGraphicsItem. By default, the exposedRect is initialized to the item's boundingRect() and the matrix is untransformed. You can enable this flag for the style options to be set up with more fine-grained values. Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag and always initialized to 1. Use QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher value. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemHasNoContents

0x400

The item does not paint anything (i.e., calling paint() on the item has no effect). You should set this flag on items that do not need to be painted to ensure that Graphics View avoids unnecessary painting preparations. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemSendsGeometryChanges

0x800

The item enables itemChange() notifications for ItemPositionChange, ItemPositionHasChanged, ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For performance reasons, these notifications are disabled by default. You must enable this flag to receive notifications for position and transform changes. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemAcceptsInputMethod

0x1000

The item supports input methods typically used for Asian languages. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemNegativeZStacksBehindParent

0x2000

The item automatically stacks behind it's parent if it's z-value is negative. This flag enables setZValue() to toggle ItemStacksBehindParent. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemIsPanel

0x4000

The item is a panel. A panel provides activation and contained focus handling. Only one panel can be active at a time (see QGraphicsItem::isActive()). When no panel is active, QGraphicsScene activates all non-panel items. Window items (i.e., QGraphicsItem::isWindow() returns true) are panels. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemSendsScenePositionChanges

0x10000

The item enables itemChange() notifications for ItemScenePositionHasChanged. For performance reasons, these notifications are disabled by default. You must enable this flag to receive notifications for scene position changes. This flag was introduced in Qt 4.6.

QGraphicsItem::ItemContainsChildrenInShape

0x80000

This flag indicates that all of the item's direct or indirect children only draw within the item's shape. Unlike ItemClipsChildrenToShape, this restriction is not enforced. Set ItemContainsChildrenInShape when you manually assure that drawing is bound to the item's shape and want to avoid the cost associated with enforcing the clip. Setting this flag enables more efficient drawing and collision detection. The flag is disabled by default.

Note: If both this flag and ItemClipsChildrenToShape are set, the clip will be enforced. This is equivalent to just setting ItemClipsChildrenToShape.

This flag was introduced in Qt 5.4.

The GraphicsItemFlags type is a typedef for QFlags. It stores an OR combination of GraphicsItemFlag values.

你可能感兴趣的:(Qt学习)