#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlinfo.h>
#include <QtGui/qpen.h>
-#include <QtGui/qcursor.h>
#include <QtGui/qguiapplication.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qinputmethod.h>
#include <QtCore/qdebug.h>
#include <QtCore/qcoreevent.h>
QT_BEGIN_NAMESPACE
+#ifdef FOCUS_DEBUG
+void printFocusTree(QQuickItem *item, QQuickItem *scope = 0, int depth = 1);
+void printFocusTree(QQuickItem *item, QQuickItem *scope, int depth)
+{
+ qWarning()
+ << QByteArray(depth, '\t').constData()
+ << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ')
+ << item->hasFocus()
+ << item->hasActiveFocus()
+ << item->isFocusScope()
+ << item;
+ foreach (QQuickItem *child, item->childItems()) {
+ printFocusTree(
+ child,
+ item->isFocusScope() || !scope ? item : scope,
+ item->isFocusScope() || !scope ? depth + 1 : depth);
+ }
+}
+#endif
+
static void QQuickItem_parentNotifier(QObject *o, intptr_t, QQmlNotifier **n)
{
QQuickItemPrivate *d = QQuickItemPrivate::get(static_cast<QQuickItem *>(o));
\qmlclass Transform QQuickTransform
\inqmlmodule QtQuick 2
\ingroup qml-transform-elements
- \brief The Transform elements provide a way of building advanced transformations on Items.
+ \brief For specifying advanced transformations on Items
The Transform element is a base type which cannot be instantiated directly.
The following concrete Transform types are available:
\qmlclass Translate QQuickTranslate
\inqmlmodule QtQuick 2
\ingroup qml-transform-elements
- \brief The Translate object provides a way to move an Item without changing its x or y properties.
+ \brief Provides a way to move an Item without changing its x or y properties
The Translate object provides independent control over position in addition to the Item's x and y properties.
\qmlclass Scale QQuickScale
\inqmlmodule QtQuick 2
\ingroup qml-transform-elements
- \brief The Scale element provides a way to scale an Item.
+ \brief Provides a way to scale an Item
The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically,
it allows a different scale for the x and y axes, and allows the scale to be relative to an
\qmlclass Rotation QQuickRotation
\inqmlmodule QtQuick 2
\ingroup qml-transform-elements
- \brief The Rotation object provides a way to rotate an Item.
+ \brief Provides a way to rotate an Item
The Rotation object gives more control over rotation than using \l Item's \l{Item::rotation}{rotation} property.
Specifically, it allows (z axis) rotation to be relative to an arbitrary point.
rotations you must specify the axis to rotate around in addition to the origin point.
The following example shows various 3D-like rotations applied to an \l Image.
- \snippet doc/src/snippets/qml/rotation.qml 0
+ \snippet doc/snippets/qml/rotation.qml 0
\image axisrotation.png
\qmlclass KeyNavigation QQuickKeyNavigationAttached
\inqmlmodule QtQuick 2
\ingroup qml-basic-interaction-elements
- \brief The KeyNavigation attached property supports key navigation by arrow keys.
+ \brief Supports key navigation by arrow keys
Key-based user interfaces commonly allow the use of arrow keys to navigate between
focusable items. The KeyNavigation attached property enables this behavior by providing a
The following example provides key navigation for a 2x2 grid of items:
- \snippet doc/src/snippets/qml/keynavigation.qml 0
+ \snippet doc/snippets/qml/keynavigation.qml 0
The top-left item initially receives focus by setting \l {Item::}{focus} to
\c true. When an arrow key is pressed, the focus will move to the
QQuickKeyNavigationAttached::QQuickKeyNavigationAttached(QObject *parent)
: QObject(*(new QQuickKeyNavigationAttachedPrivate), parent),
- QQuickItemKeyFilter(qobject_cast<QQuickItem*>(parent))
+ QQuickItemKeyFilter(qmlobject_cast<QQuickItem*>(parent))
{
m_processPost = true;
}
{ 0, 0 }
};
-bool QQuickKeysAttachedPrivate::isConnected(const char *signalName)
+bool QQuickKeysAttached::isConnected(const char *signalName)
{
- return isSignalConnected(signalIndex(signalName));
+ Q_D(QQuickKeysAttached);
+ //### doing two string-based lookups isn't ideal
+ int signal_index = d->signalIndex(signalName);
+ int index = metaObject()->indexOfSignal(signalName);
+ return QQml_isSignalConnected(this, signal_index, index);
}
/*!
\qmlclass Keys QQuickKeysAttached
\inqmlmodule QtQuick 2
\ingroup qml-basic-interaction-elements
- \brief The Keys attached property provides key handling to Items.
+ \brief Provides key handling to Items
All visual primitives support key handling via the Keys
attached property. Keys can be handled via the onPressed
be used to test for a certain key; in this case, the left cursor
key:
- \snippet doc/src/snippets/qml/keys/keys-pressed.qml key item
+ \snippet doc/snippets/qml/keys/keys-pressed.qml key item
Some keys may alternatively be handled via specific signal properties,
for example \e onSelectPressed. These handlers automatically set
\e event.accepted to true.
- \snippet doc/src/snippets/qml/keys/keys-handler.qml key item
+ \snippet doc/snippets/qml/keys/keys-handler.qml key item
See \l{Qt::Key}{Qt.Key} for the list of keyboard codes.
QQuickKeysAttached::QQuickKeysAttached(QObject *parent)
: QObject(*(new QQuickKeysAttachedPrivate), parent),
- QQuickItemKeyFilter(qobject_cast<QQuickItem*>(parent))
+ QQuickItemKeyFilter(qmlobject_cast<QQuickItem*>(parent))
{
Q_D(QQuickKeysAttached);
m_processPost = false;
- d->item = qobject_cast<QQuickItem*>(parent);
+ d->item = qmlobject_cast<QQuickItem*>(parent);
}
QQuickKeysAttached::~QQuickKeysAttached()
QByteArray keySignal = keyToSignal(event->key());
if (!keySignal.isEmpty()) {
keySignal += "(QQuickKeyEvent*)";
- if (d->isConnected(keySignal)) {
+ if (isConnected(keySignal)) {
// If we specifically handle a key then default to accepted
ke.setAccepted(true);
int idx = QQuickKeysAttached::staticMetaObject.indexOfSignal(keySignal);
\qmlclass LayoutMirroring QQuickLayoutMirroringAttached
\inqmlmodule QtQuick 2
\ingroup qml-utility-elements
- \brief The LayoutMirroring attached property is used to mirror layout behavior.
+ \brief Property used to mirror layout behavior
The LayoutMirroring attached property is used to horizontally mirror \l {anchor-layout}{Item anchors},
\l{Using QML Positioner and Repeater Items}{positioner} elements (such as \l Row and \l Grid)
from left to right by default, they are now positioned from right to left instead, as demonstrated
by the numbering and opacity of the items:
- \snippet doc/src/snippets/qml/layoutmirroring.qml 0
+ \snippet doc/snippets/qml/layoutmirroring.qml 0
\image layoutmirroring.png
if (isMirrorImplicit)
setLayoutMirror(inherit ? inheritedLayoutMirror : false);
for (int i = 0; i < childItems.count(); ++i) {
- if (QQuickItem *child = qobject_cast<QQuickItem *>(childItems.at(i))) {
+ if (QQuickItem *child = qmlobject_cast<QQuickItem *>(childItems.at(i))) {
QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child);
childPrivate->setImplicitLayoutMirror(inheritedLayoutMirror, inheritMirrorFromParent);
}
if (item->d_func()->isAccessible)
break; // already set - grandparents should have the flag set as well.
- if (item->canvas() && item->canvas()->rootItem() == item)
- break; // don't add a listener to the canvas root item
-
item->d_func()->isAccessible = true;
item = item->d_func()->parentItem;
}
/*!
\class QQuickItem
- \brief The QQuickItem class provides the most basic of all visual items in QML.
+ \brief Provides the most basic of all visual items in QML
\inmodule QtQuick
common across visual items - such as the x and y position, the
width and height, \l {anchor-layout}{anchoring} and key handling.
- You can subclass QQuickItem to provide your own custom visual item that inherits
- these features. Note that, because it does not draw anything, QQuickItem sets the
- QGraphicsItem::ItemHasNoContents flag. If you subclass QQuickItem to create a visual
- item, you will need to unset this flag.
+ You can subclass QQuickItem to provide your own custom visual item
+ that inherits these features.
+
+ \section1 Custom Items using Scene Graph
+
+ All visual QML items are rendered using the scene graph, a
+ low-level, high-performance rendering stack, closely tied to
+ OpenGL. It is possible for subclasses of QQuickItem to add their
+ own custom content into the scene graph by setting the
+ QQuickItem::ItemHasContents flag and reimplementing the
+ QQuickItem::updatePaintNode() function.
+
+ \warning It is crucial that OpenGL operations and interaction with
+ the scene graph happens exclusively on the rendering thread,
+ primarily during the updatePaintNode() call. The best rule of
+ thumb is to only use classes with the "QSG" prefix inside the
+ QQuickItem::updatePaintNode() function.
+ To read more about how the scene graph rendering works, see
+ \l{Scene Graph and Rendering}
+
+ \section1 Custom Items using QPainter
+
+ The QQuickItem provides a subclass, QQuickPaintedItem, which
+ allows the users to render content using QPainter.
+
+ \warning Using QQuickPaintedItem uses an indirect 2D surface to
+ render its content, either using software rasterization or using
+ an OpenGL framebuffer object (FBO), so the rendering is a two-step
+ operation. First rasterize the surface, then draw the
+ surface. Using scene graph API directly is always significantly
+ faster.
+
+ \sa QQuickCanvas, QQuickPaintedItem
*/
/*!
\inherits QtObject
\inqmlmodule QtQuick 2
\ingroup qml-basic-visual-elements
- \brief The Item is the most basic of all visual items in QML.
+ \brief A basic visual QML type
All visual items in Qt Quick inherit from Item. Although Item
has no visual appearance, it defines all the properties that are
if (d->canvas) {
QQuickCanvasPrivate::get(d->canvas)->clearFocusInScope(scopeItem, scopeFocusedItem,
QQuickCanvasPrivate::DontChangeFocusProperty);
+ if (scopeFocusedItem != this)
+ QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true);
} else {
QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, false);
}
while (!scopeItem->isFocusScope() && scopeItem->parentItem())
scopeItem = scopeItem->parentItem();
- if (scopeItem->scopedFocusItem()) {
+ if (QQuickItemPrivate::get(scopeItem)->subFocusItem
+ || (!scopeItem->isFocusScope() && scopeItem->hasFocus())) {
+ if (scopeFocusedItem != this)
+ QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, false);
QQuickItemPrivate::get(scopeFocusedItem)->focus = false;
emit scopeFocusedItem->focusChanged(false);
} else {
return d->parentItem;
}
-QSGEngine *QQuickItem::sceneGraphEngine() const
-{
- return canvas()->sceneGraphEngine();
-}
-
QQuickCanvas *QQuickItem::canvas() const
{
Q_D(const QQuickItem);
QQuickItem *that = static_cast<QQuickItem *>(prop->object);
- // This test is measurably (albeit only slightly) faster than qobject_cast<>()
- const QMetaObject *mo = o->metaObject();
- while (mo && mo != &QQuickItem::staticMetaObject) {
- mo = mo->d.superdata;
- }
-
- if (mo) {
- QQuickItem *item = static_cast<QQuickItem *>(o);
+ if (QQuickItem *item = qmlobject_cast<QQuickItem *>(o)) {
item->setParentItem(that);
} else {
if (o->inherits("QGraphicsItem"))
/*!
\property QQuickItem::childrenRect
- \brief The geometry of an item's children.
+ \brief Specifies the geometry of an item's children
This property holds the (collective) position and size of the item's children.
*/
\qmlproperty real QtQuick2::Item::anchors.baselineOffset
\qmlproperty bool QtQuick2::Item::anchors.mirrored
+ \qmlproperty bool QtQuick2::Item::anchors.alignWhenCentered
Anchors provide a way to position an item by specifying its
relationship with other items.
\c anchors.mirrored returns true it the layout has been \l {LayoutMirroring}{mirrored}.
+ \c anchors.alignWhenCentered (default true) forces centered anchors to align to a
+ whole pixel, i.e. if the item being centered has an odd width/height the item
+ will be positioned on a whole pixel rather than being placed on a half-pixel.
+ This ensures the item is painted crisply. There are cases where this is not
+ desirable, for example when rotating the item jitters may be apparent as the
+ center is rounded.
+
\note You can only anchor an item to siblings or a parent.
For more information see \l {anchor-layout}{Anchor Layouts}.
/*!
\property QQuickItem::baselineOffset
- \brief The position of the item's baseline in local coordinates.
+ \brief Speciifies the position of the item's baseline in local coordinates
The baseline of a \l Text item is the imaginary line on which the text
sits. Controls containing text usually set their baseline to the
}
/*!
- Called by the rendering thread when it is time to sync the state of the QML objects with the
- scene graph objects. The function should return the root of the scene graph subtree for
- this item. \a oldNode is the node that was returned the last time the function was called.
+ Called by the rendering thread, as a result of
+ QQuickItem::update(), when it is time to sync the state of the QML
+ objects with the scene graph objects.
+
+ The function should return the root of the scene graph subtree for
+ this item. Most implementations will return a single
+ QSGGeometryNode containing the visual representation of this item.
+ \a oldNode is the node that was returned the last time the
+ function was called.
+
+ \code
+ QSGNode *MyItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
+ {
+ QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(node);
+ if (!n) {
+ n = new QSGSimpleRectNode();
+ n->setColor(Qt::red);
+ }
+ n->setRect(boundingRect());
+ return n;
+ }
+ \endcode
The main thread is blocked while this function is executed so it is safe to read
values from the QQuickItem instance and other objects in the main thread.
- \warning This is the only function in which it is allowed to make use of scene graph
- objects from the main thread. Use of scene graph objects outside this function will
- result in race conditions and potential crashes.
+ If no call to QQuickItem::updatePaintNode() result in actual scene graph
+ changes, like QSGNode::markDirty() or adding and removing nodes, then
+ the underlying implementation may decide to not render the scene again as
+ the visual outcome is identical.
+
+ \warning It is crucial that OpenGL operations and interaction with
+ the scene graph happens exclusively on the rendering thread,
+ primarily during the QQuickItem::updatePaintNode() call. The best
+ rule of thumb is to only use classes with the "QSG" prefix inside
+ the QQuickItem::updatePaintNode() function.
+
+ \sa QSGMaterial, QSGSimpleMaterial, QSGGeometryNode, QSGGeometry,
+ QSGFlatColorMaterial, QSGTextureMaterial, QSGNode::markDirty()
*/
QSGNode *QQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
emit baselineOffsetChanged(offset);
}
+
+/*!
+ * Schedules a call to updatePaintNode() for this item.
+ *
+ * The call to QQuickItem::updatePaintNode() will always happen if the
+ * item is showing in a QQuickCanvas.
+ *
+ * Only items which specifies QQuickItem::ItemHasContents are allowed
+ * to call QQuickItem::update().
+ */
void QQuickItem::update()
{
Q_D(QQuickItem);
}
}
+/*!
+ \qmlmethod object QtQuick2::Item::mapFromItem(Item item, real x, real y)
+ \qmlmethod object QtQuick2::Item::mapFromItem(Item item, real x, real y, real width, real height)
+
+ Maps the point (\a x, \a y) or rect (\a x, \a y, \a width, \a height), which is in \a
+ item's coordinate system, to this item's coordinate system, and returns an object with \c x and
+ \c y (and optionally \c width and \c height) properties matching the mapped coordinate.
+
+ If \a item is a \c null value, this maps the point or rect from the coordinate system of
+ the root QML view.
+*/
void QQuickItem::mapFromItem(QQmlV8Function *args) const
{
if (args->Length() != 0) {
qreal x = (args->Length() > 1)?(*args)[1]->NumberValue():0;
qreal y = (args->Length() > 2)?(*args)[2]->NumberValue():0;
- QPointF p = mapFromItem(itemObj, QPointF(x, y));
+ if (args->Length() > 3) {
+ qreal w = (*args)[3]->NumberValue();
+ qreal h = (args->Length() > 4)?(*args)[4]->NumberValue():0;
- rv->Set(v8::String::New("x"), v8::Number::New(p.x()));
- rv->Set(v8::String::New("y"), v8::Number::New(p.y()));
+ QRectF r = mapRectFromItem(itemObj, QRectF(x, y, w, h));
+
+ rv->Set(v8::String::New("x"), v8::Number::New(r.x()));
+ rv->Set(v8::String::New("y"), v8::Number::New(r.y()));
+ rv->Set(v8::String::New("width"), v8::Number::New(r.width()));
+ rv->Set(v8::String::New("height"), v8::Number::New(r.height()));
+ } else {
+ QPointF p = mapFromItem(itemObj, QPointF(x, y));
+
+ rv->Set(v8::String::New("x"), v8::Number::New(p.x()));
+ rv->Set(v8::String::New("y"), v8::Number::New(p.y()));
+ }
}
}
return t;
}
+/*!
+ \qmlmethod object QtQuick2::Item::mapToItem(Item item, real x, real y)
+ \qmlmethod object QtQuick2::Item::mapToItem(Item item, real x, real y, real width, real height)
+
+ Maps the point (\a x, \a y) or rect (\a x, \a y, \a width, \a height), which is in this
+ item's coordinate system, to \a item's coordinate system, and returns an object with \c x and
+ \c y (and optionally \c width and \c height) properties matching the mapped coordinate.
+
+ If \a item is a \c null value, this maps the point or rect to the coordinate system of the
+ root QML view.
+*/
void QQuickItem::mapToItem(QQmlV8Function *args) const
{
if (args->Length() != 0) {
qreal x = (args->Length() > 1)?(*args)[1]->NumberValue():0;
qreal y = (args->Length() > 2)?(*args)[2]->NumberValue():0;
- QPointF p = mapToItem(itemObj, QPointF(x, y));
+ if (args->Length() > 3) {
+ qreal w = (*args)[3]->NumberValue();
+ qreal h = (args->Length() > 4)?(*args)[4]->NumberValue():0;
- rv->Set(v8::String::New("x"), v8::Number::New(p.x()));
- rv->Set(v8::String::New("y"), v8::Number::New(p.y()));
+ QRectF r = mapRectToItem(itemObj, QRectF(x, y, w, h));
+
+ rv->Set(v8::String::New("x"), v8::Number::New(r.x()));
+ rv->Set(v8::String::New("y"), v8::Number::New(r.y()));
+ rv->Set(v8::String::New("width"), v8::Number::New(r.width()));
+ rv->Set(v8::String::New("height"), v8::Number::New(r.height()));
+ } else {
+ QPointF p = mapToItem(itemObj, QPointF(x, y));
+
+ rv->Set(v8::String::New("x"), v8::Number::New(p.x()));
+ rv->Set(v8::String::New("y"), v8::Number::New(p.y()));
+ }
}
}
_stateGroup = new QQuickStateGroup;
if (!componentComplete)
_stateGroup->classBegin();
- FAST_CONNECT(_stateGroup, SIGNAL(stateChanged(QString)),
- q, SIGNAL(stateChanged(QString)))
+ qmlobject_connect(_stateGroup, QQuickStateGroup, SIGNAL(stateChanged(QString)),
+ q, QQuickItem, SIGNAL(stateChanged(QString)))
}
return _stateGroup;
/*! \internal */
// XXX todo - do we want/need this anymore?
-// Note that it's now used for varying clip rect
QRectF QQuickItem::boundingRect() const
{
Q_D(const QQuickItem);
return QRectF(0, 0, d->width, d->height);
}
+/*! \internal */
+QRectF QQuickItem::clipRect() const
+{
+ Q_D(const QQuickItem);
+ return QRectF(0, 0, d->width, d->height);
+}
+
+
QQuickItem::TransformOrigin QQuickItem::transformOrigin() const
{
Q_D(const QQuickItem);
return;
d->explicitVisible = v;
+ if (!v)
+ d->dirty(QQuickItemPrivate::Visible);
const bool childVisibilityChanged = d->setEffectiveVisibleRecur(d->calcEffectiveVisible());
if (childVisibilityChanged && d->parentItem)
for (int ii = 0; ii < childItems.count(); ++ii) {
QQuickItemPrivate::get(childItems.at(ii))->setEffectiveEnableRecur(
- flags & QQuickItem::ItemIsFocusScope ? q : scope, newEffectiveEnable);
+ (flags & QQuickItem::ItemIsFocusScope) && scope ? q : scope, newEffectiveEnable);
}
if (canvas && scope && effectiveEnable && focus) {
/*!
\property QQuickItem::smooth
- \brief whether the item is smoothed or not.
+ \brief Specifies whether the item is smoothed or not
Primarily used in image based elements to decide if the item should use smooth
sampling or not. Smooth sampling is performed using linear interpolation, while
void QQuickItemPrivate::implicitWidthChanged()
{
Q_Q(QQuickItem);
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
+ const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii);
+ if (change.types & QQuickItemPrivate::ImplicitWidth) {
+ change.listener->itemImplicitWidthChanged(q);
+ }
+ }
emit q->implicitWidthChanged();
}
if (d->width == w || widthValid()) {
if (changed)
d->implicitWidthChanged();
- return;
+ if (d->width == w || widthValid())
+ return;
+ changed = false;
}
qreal oldWidth = d->width;
void QQuickItemPrivate::implicitHeightChanged()
{
Q_Q(QQuickItem);
+ for (int ii = 0; ii < changeListeners.count(); ++ii) {
+ const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii);
+ if (change.types & QQuickItemPrivate::ImplicitHeight) {
+ change.listener->itemImplicitHeightChanged(q);
+ }
+ }
emit q->implicitHeightChanged();
}
if (d->height == h || heightValid()) {
if (changed)
d->implicitHeightChanged();
- return;
+ if (d->height == h || heightValid())
+ return;
+ changed = false;
}
qreal oldHeight = d->height;
if (d->width == w || widthValid()) {
if (wChanged)
d->implicitWidthChanged();
- wDone = true;
+ wDone = d->width == w || widthValid();
+ wChanged = false;
}
if (d->height == h || heightValid()) {
if (hChanged)
d->implicitHeightChanged();
- hDone = true;
+ hDone = d->height == h || heightValid();
+ hChanged = false;
}
if (wDone && hDone)
return;
QVarLengthArray<QQuickItem *, 20> changed;
QQuickItem *oldSubFocusItem = QQuickItemPrivate::get(scope)->subFocusItem;
if (oldSubFocusItem) {
+ QQuickItemPrivate::get(oldSubFocusItem)->updateSubFocusItem(scope, false);
QQuickItemPrivate::get(oldSubFocusItem)->focus = false;
changed << oldSubFocusItem;
}
if (!d->canvas)
return false;
- QPoint cursorPos = QCursor::pos();
- if (QRectF(0, 0, width(), height()).contains(mapFromScene(cursorPos))) // ### refactor: d->canvas->mapFromGlobal(cursorPos))))
- return true;
- return false;
+ QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition;
+ return contains(mapFromScene(cursorPos)); // ### refactor: d->canvas->mapFromGlobal(cursorPos))))
}
bool QQuickItem::acceptHoverEvents() const
}
/*!
- \qmlmethod object QtQuick2::Item::mapFromItem(Item item, real x, real y)
+ Returns true if this item contains \a point, which is in local coordinates;
+ returns false otherwise.
- Maps the point (\a x, \a y), which is in \a item's coordinate system, to
- this item's coordinate system, and returns an object with \c x and \c y
- properties matching the mapped coordinate.
+ This function can be overwritten in order to handle point collisions in items
+ with custom shapes. The default implementation checks if the point is inside
+ the item's bounding rect.
- If \a item is a \c null value, this maps the point from the coordinate
- system of the root QML view.
+ Note that it's normally used to check if the item is under the mouse cursor,
+ and for that reason, the implementation of this function should be as light-weight
+ as possible.
*/
-/*!
- \qmlmethod object QtQuick2::Item::mapToItem(Item item, real x, real y)
-
- Maps the point (\a x, \a y), which is in this item's coordinate system, to
- \a item's coordinate system, and returns an object with \c x and \c y
- properties matching the mapped coordinate.
+bool QQuickItem::contains(const QPointF &point) const
+{
+ Q_D(const QQuickItem);
+ return QRectF(0, 0, d->width, d->height).contains(point);
+}
- If \a item is a \c null value, this maps \a x and \a y to the coordinate
- system of the root QML view.
-*/
QPointF QQuickItem::mapToItem(const QQuickItem *item, const QPointF &point) const
{
QPointF p = mapToScene(point);
Q_ASSERT(m_effectComponent);
Q_ASSERT(!m_effect);
- QObject *created = m_effectComponent->create();
+ QObject *created = m_effectComponent->beginCreate(m_effectComponent->creationContext());
m_effect = qobject_cast<QQuickItem *>(created);
if (!m_effect) {
qWarning("Item: layer.effect is not a QML Item.");
+ m_effectComponent->completeCreate();
delete created;
return;
}
}
m_effect->setVisible(m_item->isVisible());
m_effect->setProperty(m_name, qVariantFromValue<QObject *>(m_effectSource));
+ m_effectComponent->completeCreate();
}
void QQuickItemLayer::deactivateEffect()
{
QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
Q_ASSERT(l);
- QRectF bounds = m_item->boundingRect();
+ QRectF bounds = m_item->clipRect();
l->setWidth(bounds.width());
l->setHeight(bounds.height());
l->setX(bounds.x() + m_item->x());