Qt 4.8
Item Class Reference

The Item is the most basic of all visual items in QML. More...

Inheritance diagram for Item:
BorderImage Column Flickable Flipable Flow FocusPanel FocusScope GestureArea Grid Image Loader MouseArea Particles PathView PinchArea Rectangle Repeater Row ShaderEffectItem Text TextEdit TextInput

Detailed Description

The Item is the most basic of all visual items in QML.

Since
4.7

All visual items in Qt Declarative inherit from Item. Although Item 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, anchor-layout{anchoring} and key handling.

Item is also useful for grouping items together.

source: "tile.png"
}
x: 80
width: 100
height: 100
source: "tile.png"
}
x: 190
width: 100
height: 100
fillMode: Image.Tile
source: "tile.png"
}
}

Key Handling

Key handling is available to all Item-based visual elements via the Keys{Keys} attached property. The Keys attached property provides basic handlers such as Keys::onPressed{onPressed} and Keys::onReleased{onReleased}, as well as handlers for specific keys, such as Keys::onCancelPressed{onCancelPressed}. The example below assigns qmlfocus{focus} to the item and handles the Left key via the general onPressed handler and the Select key via the onSelectPressed handler:

focus: true
Keys.onPressed: {
if (event.key == Qt.Key_Left) {
console.log("move left");
event.accepted = true;
}
}
Keys.onSelectPressed: console.log("Selected");
}

See the Keys{Keys} attached property for detailed documentation.

Layout Mirroring

Item layouts can be mirrored using the LayoutMirroring{LayoutMirroring} attached property.


The documentation for this class was generated from the following file: