Kirigami2

scenepositionattached.h
1 /*
2  * SPDX-FileCopyrightText: 2018 Marco Martin <[email protected]>
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 <QtQml>
12 
13 class 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 2.5 as Kirigami
20  * Text {
21  * text: ScenePosition.x
22  * }
23  * @endcode
24  * @since 2.3
25  */
27 {
28  Q_OBJECT
29  /**
30  * The global scene X position
31  */
32  Q_PROPERTY(int x READ x NOTIFY xChanged)
33 
34  /**
35  * The global scene Y position
36  */
37  Q_PROPERTY(int y READ y NOTIFY yChanged)
38 
39 public:
40  explicit ScenePositionAttached(QObject *parent = nullptr);
41  ~ScenePositionAttached() override;
42 
43  int x() const;
44  int y() const;
45 
46  // QML attached property
47  static ScenePositionAttached *qmlAttachedProperties(QObject *object);
48 
49 Q_SIGNALS:
50  void xChanged();
51  void yChanged();
52 
53 private:
54  void connectAncestors(QQuickItem *item);
55 
56  QQuickItem *m_item = nullptr;
57  QList<QQuickItem *> m_ancestors;
58 };
59 
60 QML_DECLARE_TYPEINFO(ScenePositionAttached, QML_HAS_ATTACHED_PROPERTIES)
61 
62 #endif // SCENEPOSITIONATTACHED_H
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
int x
The global scene X position.
This attached property contains the information about the scene position of the item: Its global x an...
Q_SIGNALSQ_SIGNALS
int y
The global scene Y position.
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.