Kirigami2

scenepositionattached.h
1/*
2 * SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef SCENEPOSITIONATTACHED_H
8#define SCENEPOSITIONATTACHED_H
9
10#include <QObject>
11#include <QQmlEngine>
12
13class QQuickItem;
14
15/**
16 * This attached property contains the information about the scene position of the item:
17 * Its global x and y coordinates will update automatically and can be binded
18 * @code
19 * import org.kde.kirigami as Kirigami
20 * Text {
21 * text: ScenePosition.x
22 * }
23 * @endcode
24 * @since 2.3
25 */
27{
29 QML_ELEMENT
30 QML_ATTACHED(ScenePositionAttached)
31 QML_NAMED_ELEMENT(ScenePosition)
32 QML_UNCREATABLE("")
33 /**
34 * The global scene X position
35 */
36 Q_PROPERTY(qreal x READ x NOTIFY xChanged FINAL)
37
38 /**
39 * The global scene Y position
40 */
41 Q_PROPERTY(qreal y READ y NOTIFY yChanged FINAL)
42
43public:
44 explicit ScenePositionAttached(QObject *parent = nullptr);
45 ~ScenePositionAttached() override;
46
47 qreal x() const;
48 qreal y() const;
49
50 // QML attached property
51 static ScenePositionAttached *qmlAttachedProperties(QObject *object);
52
54 void xChanged();
55 void yChanged();
56
57private:
58 void connectAncestors(QQuickItem *item);
59
60 QQuickItem *m_item = nullptr;
61 QList<QQuickItem *> m_ancestors;
62};
63
64QML_DECLARE_TYPEINFO(ScenePositionAttached, QML_HAS_ATTACHED_PROPERTIES)
65
66#endif // SCENEPOSITIONATTACHED_H
This attached property contains the information about the scene position of the item: Its global x an...
qreal y
The global scene Y position.
QML_ELEMENTqreal x
The global scene X position.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 12:00:02 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.