|  | Home · All Classes · Modules

# QDeclarativeItem Class Reference
[QtDeclarative module]

The QDeclarativeItem class provides the most basic of all visual items in QML. More...

Inherits QGraphicsObject and QDeclarativeParserStatus.

### Types

- enum TransformOrigin { TopLeft, Top, TopRight, Left, ..., BottomRight }

### Methods

- __init__ (self, QDeclarativeItem parent = None)
- float baselineOffset (self)
- QRectF boundingRect (self)
- QRectF childrenRect (self)
- classBegin (self)
- bool clip (self)
- componentComplete (self)
- bool event (self, QEvent)
- geometryChanged (self, QRectF newGeometry, QRectF oldGeometry)
- bool hasFocus (self)
- bool heightValid (self)
- float implicitHeight (self)
- float implicitWidth (self)
- inputMethodEvent (self, QInputMethodEvent)
- QVariant inputMethodQuery (self, Qt.InputMethodQuery query)
- bool isComponentComplete (self)
- QVariant itemChange (self, QGraphicsItem.GraphicsItemChange, QVariant)
- bool keepMouseGrab (self)
- keyPressEvent (self, QKeyEvent event)
- keyReleaseEvent (self, QKeyEvent event)
- paint (self, QPainter, QStyleOptionGraphicsItem, QWidget)
- QDeclarativeItem parentItem (self)
- bool sceneEvent (self, QEvent)
- setBaselineOffset (self, float)
- setClip (self, bool)
- setHeight (self, float)
- setImplicitHeight (self, float)
- setImplicitWidth (self, float)
- setKeepMouseGrab (self, bool)
- setParentItem (self, QDeclarativeItem parent)
- setSmooth (self, bool)
- setTransformOrigin (self, TransformOrigin)
- setWidth (self, float)
- bool smooth (self)
- TransformOrigin transformOrigin (self)
- bool widthValid (self)

## Detailed Description

The QDeclarativeItem class provides the most basic of all visual items in QML.

All visual items in Qt Declarative inherit from QDeclarativeItem. Although QDeclarativeItem has no visual appearance, it defines all the properties that are common across visual items - such as the x and y position, the width and height, anchoring and key handling.

You can subclass QDeclarativeItem to provide your own custom visual item that inherits these features. Note that, because it does not draw anything, QDeclarativeItem sets the QGraphicsItem.ItemHasNoContents flag. If you subclass QDeclarativeItem to create a visual item, you will need to unset this flag.

## Type Documentation

### QDeclarativeItem.TransformOrigin

Controls the point about which simple transforms like scale apply.

Constant | Value | Description
--- | --- | ---
`QDeclarativeItem.TopLeft` | `0` | The top-left corner of the item.
`QDeclarativeItem.Top` | `1` | The center point of the top of the item.
`QDeclarativeItem.TopRight` | `2` | The top-right corner of the item.
`QDeclarativeItem.Left` | `3` | The left most point of the vertical middle.
`QDeclarativeItem.Center` | `4` | The center of the item.
`QDeclarativeItem.Right` | `5` | The right most point of the vertical middle.
`QDeclarativeItem.BottomLeft` | `6` | The bottom-left corner of the item.
`QDeclarativeItem.Bottom` | `7` | The center point of the bottom of the item.
`QDeclarativeItem.BottomRight` | `8` | The bottom-right corner of the item.

## Method Documentation

### QDeclarativeItem.__init__ (self, QDeclarativeItem parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a QDeclarativeItem with the given parent.

### float QDeclarativeItem.baselineOffset (self)

### QRectF QDeclarativeItem.boundingRect (self)

### QRectF QDeclarativeItem.childrenRect (self)

### QDeclarativeItem.classBegin (self)

### bool QDeclarativeItem.clip (self)

### QDeclarativeItem.componentComplete (self)

### bool QDeclarativeItem.event (self, QEvent)

### QDeclarativeItem.geometryChanged (self, QRectF newGeometry, QRectF oldGeometry)

This function is called to handle this item's changes in geometry from oldGeometry to newGeometry. If the two geometries are the same, it doesn't do anything.

### bool QDeclarativeItem.hasFocus (self)

### bool QDeclarativeItem.heightValid (self)

Returns whether the height property has been set explicitly.

### float QDeclarativeItem.implicitHeight (self)

### float QDeclarativeItem.implicitWidth (self)

### QDeclarativeItem.inputMethodEvent (self, QInputMethodEvent)

### QVariant QDeclarativeItem.inputMethodQuery (self, Qt.InputMethodQuery query)

### bool QDeclarativeItem.isComponentComplete (self)

Returns true if construction of the QML component is complete; otherwise returns false.

It is often desirable to delay some processing until the component is completed.

See also componentComplete().

### QVariant QDeclarativeItem.itemChange (self, QGraphicsItem.GraphicsItemChange, QVariant)

### bool QDeclarativeItem.keepMouseGrab (self)

Returns a value indicating whether mouse input should remain with this item exclusively.

See also setKeepMouseGrab().

### QDeclarativeItem.keyPressEvent (self, QKeyEvent event)

### QDeclarativeItem.keyReleaseEvent (self, QKeyEvent event)

### QDeclarativeItem.paint (self, QPainter, QStyleOptionGraphicsItem, QWidget)

### QDeclarativeItem QDeclarativeItem.parentItem (self)

### bool QDeclarativeItem.sceneEvent (self, QEvent)

### QDeclarativeItem.setBaselineOffset (self, float)

### QDeclarativeItem.setClip (self, bool)

### QDeclarativeItem.setHeight (self, float)

### QDeclarativeItem.setImplicitHeight (self, float)

Sets the implied height of the item to h. This is the height implied by other properties that determine the content.

See also implicitHeight().

### QDeclarativeItem.setImplicitWidth (self, float)

Sets the implied width of the item to w. This is the width implied by other properties that determine the content.

See also implicitWidth().

### QDeclarativeItem.setKeepMouseGrab (self, bool)

The flag indicating whether the mouse should remain with this item is set to keep.

This is useful for items that wish to grab and keep mouse interaction following a predefined gesture. For example, an item that is interested in horizontal mouse movement may set keepMouseGrab to true once a threshold has been exceeded. Once keepMouseGrab has been set to true, filtering items will not react to mouse events.

If the item does not indicate that it wishes to retain mouse grab, a filtering item may steal the grab. For example, Flickable may attempt to steal a mouse grab if it detects that the user has begun to move the viewport.

See also keepMouseGrab().

### QDeclarativeItem.setParentItem (self, QDeclarativeItem parent)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

### QDeclarativeItem.setSmooth (self, bool)

### QDeclarativeItem.setTransformOrigin (self, TransformOrigin)

Set the transform origin.

See also transformOrigin().

### QDeclarativeItem.setWidth (self, float)

### bool QDeclarativeItem.smooth (self)

### TransformOrigin QDeclarativeItem.transformOrigin (self)

Returns the current transform origin.

See also setTransformOrigin().

### bool QDeclarativeItem.widthValid (self)

Returns whether the width property has been set explicitly.