Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickitem_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKITEM_P_H
5#define QQUICKITEM_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qquickanchors_p.h>
19#include <QtQuick/private/qquickanchors_p_p.h>
20#include <QtQuick/private/qquickitemchangelistener_p.h>
21#include <QtQuick/private/qquickevents_p_p.h>
22#include <QtQuick/private/qquickclipnode_p.h>
23#include <QtQuick/private/qquickstate_p.h>
24#include <QtQuick/private/qquickpaletteproviderprivatebase_p.h>
25#include <QtQuick/private/qquickwindow_p.h>
26#include <QtCore/private/qproperty_p.h>
27
28#if QT_CONFIG(quick_shadereffect)
29#include <QtQuick/private/qquickshadereffectsource_p.h>
30#endif
31
32#include <QtQuick/qquickitem.h>
33#include <QtQuick/qsgnode.h>
34
35#include <QtQml/private/qqmlnullablevalue_p.h>
36#include <QtQml/private/qqmlnotifier_p.h>
37#include <QtQml/private/qqmlglobal_p.h>
38#include <QtQml/private/qlazilyallocated_p.h>
39#include <QtQml/qqml.h>
40#include <QtQml/qqmlcontext.h>
41
42#include <QtCore/qlist.h>
43#include <QtCore/qdebug.h>
44#include <QtCore/qelapsedtimer.h>
45
47
48class QNetworkReply;
54
56{
57public:
59 ~QQuickContents() override;
60
61 QRectF rectF() const { return m_contents; }
62
63 inline void calcGeometry(QQuickItem *changed = nullptr);
64 void complete();
65
66protected:
67 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override;
68 void itemDestroyed(QQuickItem *item) override;
69 void itemChildAdded(QQuickItem *, QQuickItem *) override;
70 void itemChildRemoved(QQuickItem *, QQuickItem *) override;
71 //void itemVisibilityChanged(QQuickItem *item)
72
73private:
74 bool calcHeight(QQuickItem *changed = nullptr);
75 bool calcWidth(QQuickItem *changed = nullptr);
76 void updateRect();
77
78 QQuickItem *m_item;
79 QRectF m_contents;
80};
81
83{
84 bool wChanged = calcWidth(changed);
85 bool hChanged = calcHeight(changed);
86 if (wChanged || hChanged)
87 updateRect();
88}
89
91{
92 Q_DECLARE_PUBLIC(QQuickTransform)
93public:
95
97
99};
100
101#if QT_CONFIG(quick_shadereffect)
102
103class Q_QUICK_PRIVATE_EXPORT QQuickItemLayer : public QObject, public QQuickItemChangeListener
104{
106 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
107 Q_PROPERTY(QSize textureSize READ size WRITE setSize NOTIFY sizeChanged FINAL)
108 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged FINAL)
109 Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged FINAL)
110 Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged FINAL)
111 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged REVISION(6, 5) FINAL)
112 Q_PROPERTY(QQuickShaderEffectSource::WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged FINAL)
113 Q_PROPERTY(QQuickShaderEffectSource::Format format READ format WRITE setFormat NOTIFY formatChanged FINAL)
114 Q_PROPERTY(QByteArray samplerName READ name WRITE setName NOTIFY nameChanged FINAL)
115 Q_PROPERTY(QQmlComponent *effect READ effect WRITE setEffect NOTIFY effectChanged FINAL)
116 Q_PROPERTY(QQuickShaderEffectSource::TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged FINAL)
117 Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged FINAL)
120
121public:
122 QQuickItemLayer(QQuickItem *item);
123 ~QQuickItemLayer() override;
124
125 void classBegin();
126 void componentComplete();
127
128 bool enabled() const { return m_enabled; }
129 void setEnabled(bool enabled);
130
131 bool mipmap() const { return m_mipmap; }
132 void setMipmap(bool mipmap);
133
134 bool smooth() const { return m_smooth; }
135 void setSmooth(bool s);
136
137 bool live() const { return m_live; }
138 void setLive(bool live);
139
140 QSize size() const { return m_size; }
141 void setSize(const QSize &size);
142
143 QQuickShaderEffectSource::Format format() const { return m_format; }
145
146 QRectF sourceRect() const { return m_sourceRect; }
147 void setSourceRect(const QRectF &sourceRect);
148
149 QQuickShaderEffectSource::WrapMode wrapMode() const { return m_wrapMode; }
151
152 QByteArray name() const { return m_name; }
153 void setName(const QByteArray &name);
154
155 QQmlComponent *effect() const { return m_effectComponent; }
156 void setEffect(QQmlComponent *effect);
157
158 QQuickShaderEffectSource::TextureMirroring textureMirroring() const { return m_textureMirroring; }
159 void setTextureMirroring(QQuickShaderEffectSource::TextureMirroring mirroring);
160
161 int samples() const { return m_samples; }
162 void setSamples(int count);
163
164 QQuickShaderEffectSource *effectSource() const { return m_effectSource; }
165
167 void itemOpacityChanged(QQuickItem *) override;
168 void itemParentChanged(QQuickItem *, QQuickItem *) override;
169 void itemSiblingOrderChanged(QQuickItem *) override;
170 void itemVisibilityChanged(QQuickItem *) override;
171
172 void updateMatrix();
173 void updateGeometry();
174 void updateOpacity();
175 void updateZ();
176
178 void enabledChanged(bool enabled);
179 void sizeChanged(const QSize &size);
180 void mipmapChanged(bool mipmap);
181 void wrapModeChanged(QQuickShaderEffectSource::WrapMode mode);
182 void nameChanged(const QByteArray &name);
183 void effectChanged(QQmlComponent *component);
184 void smoothChanged(bool smooth);
185 void liveChanged(bool live);
186 void formatChanged(QQuickShaderEffectSource::Format format);
187 void sourceRectChanged(const QRectF &sourceRect);
188 void textureMirroringChanged(QQuickShaderEffectSource::TextureMirroring mirroring);
189 void samplesChanged(int count);
190
191private:
192 friend class QQuickTransformAnimatorJob;
193 friend class QQuickOpacityAnimatorJob;
194
195 void activate();
196 void deactivate();
197 void activateEffect();
198 void deactivateEffect();
199
200 QQuickItem *m_item;
201 bool m_enabled;
202 bool m_mipmap;
203 bool m_smooth;
204 bool m_live;
205 bool m_componentComplete;
208 QSize m_size;
209 QRectF m_sourceRect;
210 QByteArray m_name;
211 QQmlComponent *m_effectComponent;
212 QQuickItem *m_effect;
213 QQuickShaderEffectSource *m_effectSource;
215 int m_samples;
216};
217
218#endif
219
220class Q_QUICK_PRIVATE_EXPORT QQuickItemPrivate
221 : public QObjectPrivate
222 , public QQuickPaletteProviderPrivateBase<QQuickItem, QQuickItemPrivate>
223{
224 Q_DECLARE_PUBLIC(QQuickItem)
225
226public:
227 static QQuickItemPrivate* get(QQuickItem *item) { return item->d_func(); }
228 static const QQuickItemPrivate* get(const QQuickItem *item) { return item->d_func(); }
229
231 ~QQuickItemPrivate() override;
232 void init(QQuickItem *parent);
233
235 QQmlListProperty<QObject> resources();
237 QQmlListProperty<QQuickItem> visibleChildren();
238
241
242 QString state() const;
243 void setState(const QString &);
244
245 QQuickAnchorLine left() const;
246 QQuickAnchorLine right() const;
247 QQuickAnchorLine horizontalCenter() const;
248 QQuickAnchorLine top() const;
249 QQuickAnchorLine bottom() const;
250 QQuickAnchorLine verticalCenter() const;
251 QQuickAnchorLine baseline() const;
252
253#if QT_CONFIG(quick_shadereffect)
254 QQuickItemLayer *layer() const;
255#endif
256
257 void localizedTouchEvent(const QTouchEvent *event, bool isFiltering, QMutableTouchEvent *localized);
258 bool hasPointerHandlers() const;
259 bool hasEnabledHoverHandlers() const;
260 virtual void addPointerHandler(QQuickPointerHandler *h);
261 virtual void removePointerHandler(QQuickPointerHandler *h);
262
263 // data property
264 static void data_append(QQmlListProperty<QObject> *, QObject *);
265 static qsizetype data_count(QQmlListProperty<QObject> *);
266 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
267 static void data_clear(QQmlListProperty<QObject> *);
268 static void data_removeLast(QQmlListProperty<QObject> *);
269
270 // resources property
271 static QObject *resources_at(QQmlListProperty<QObject> *, qsizetype);
272 static void resources_append(QQmlListProperty<QObject> *, QObject *);
273 static qsizetype resources_count(QQmlListProperty<QObject> *);
274 static void resources_clear(QQmlListProperty<QObject> *);
275 static void resources_removeLast(QQmlListProperty<QObject> *);
276
277 // children property
278 static void children_append(QQmlListProperty<QQuickItem> *, QQuickItem *);
279 static qsizetype children_count(QQmlListProperty<QQuickItem> *);
280 static QQuickItem *children_at(QQmlListProperty<QQuickItem> *, qsizetype);
281 static void children_clear(QQmlListProperty<QQuickItem> *);
282 static void children_removeLast(QQmlListProperty<QQuickItem> *);
283
284 // visibleChildren property
286 static qsizetype visibleChildren_count(QQmlListProperty<QQuickItem> *prop);
287 static QQuickItem *visibleChildren_at(QQmlListProperty<QQuickItem> *prop, qsizetype index);
288
289 // transform property
290 static qsizetype transform_count(QQmlListProperty<QQuickTransform> *list);
291 static void transform_append(QQmlListProperty<QQuickTransform> *list, QQuickTransform *);
293 static void transform_clear(QQmlListProperty<QQuickTransform> *list);
294
295 void _q_resourceObjectDeleted(QObject *);
296 quint64 _q_createJSWrapper(QV4::ExecutionEngine *engine);
297
299 Geometry = 0x01,
300 SiblingOrder = 0x02,
301 Visibility = 0x04,
302 Opacity = 0x08,
303 Destroyed = 0x10,
304 Parent = 0x20,
305 Children = 0x40,
306 Rotation = 0x80,
307 ImplicitWidth = 0x100,
308 ImplicitHeight = 0x200,
309 Enabled = 0x400,
310 Focus = 0x800,
311 AllChanges = 0xFFFFFFFF
312 };
313
314 Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
315
317 using ChangeTypes = QQuickItemPrivate::ChangeTypes;
318
320 : listener(l)
321 , types(t)
322 , gTypes(QQuickGeometryChange::All)
323 {}
324
326 : listener(l)
327 , types(Geometry)
328 , gTypes(gt)
329 {}
330
331 bool operator==(const ChangeListener &other) const
332 { return listener == other.listener && types == other.types; }
333
336 QQuickGeometryChange gTypes; //NOTE: not used for ==
337
338#ifndef QT_NO_DEBUG_STREAM
339 private:
341#endif // QT_NO_DEBUG_STREAM
342 };
343
344 // call QQuickItemChangeListener
345 template <typename Fn, typename ...Args>
346 void notifyChangeListeners(QQuickItemPrivate::ChangeTypes changeTypes, Fn &&function, Args &&...args)
347 {
348 if (changeListeners.isEmpty())
349 return;
350
351 const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
352 for (const QQuickItemPrivate::ChangeListener &change : listeners) {
353 if (change.types & changeTypes) {
354 if constexpr (std::is_member_function_pointer_v<Fn>)
355 (change.listener->*function)(args...);
356 else
357 function(change, args...);
358 }
359 }
360 }
361
362 struct ExtraData {
363 ExtraData();
364
369
376#if QT_CONFIG(quick_shadereffect)
377 mutable QQuickItemLayer *layer;
378#endif
379#if QT_CONFIG(cursor)
381#endif
383
384 // these do not include child items
387 // updated recursively for child items as well
389 // Mask contains() method index
391
392 // Contains mask
394
398 // subsceneDeliveryAgent is set only if this item is the root of a subscene, not on all items within.
399 QQuickDeliveryAgent *subsceneDeliveryAgent = nullptr;
400
402
403 // Although acceptedMouseButtons is inside ExtraData, we actually store
404 // the LeftButton flag in the extra.tag() bit. This is because it is
405 // extremely common to set acceptedMouseButtons to LeftButton, but very
406 // rare to use any of the other buttons.
407 Qt::MouseButtons acceptedMouseButtons;
409
410 uint origin:5; // QQuickItem::TransformOrigin
412
413 // 26 bits padding
414 };
415
417 NoTag = 0x1,
418 LeftMouseButtonAccepted = 0x2
419 };
420 Q_DECLARE_FLAGS(ExtraDataTags, ExtraDataTag)
421
422 QLazilyAllocated<ExtraData, ExtraDataTags> extra;
423 // If the mask is an Item, inform it that it's being used as a mask (true) or is no longer being used (false)
424 virtual void registerAsContainmentMask(QQuickItem * /* maskedItem */, bool /* set */) { }
425
426 QQuickAnchors *anchors() const;
428
429 inline Qt::MouseButtons acceptedMouseButtons() const;
430
432
433 void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types);
434 void updateOrAddItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types);
435 void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types);
436 void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types);
437 void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types);
438
439 QQuickStateGroup *_states();
441
442 inline QQuickItem::TransformOrigin origin() const;
443
444 // Bit 0
455 // Bit 16
472 // Bit 32
479 // isTabFence: When true, the item acts as a fence within the tab focus chain.
480 // This means that the item and its children will be skipped from the tab focus
481 // chain when navigating from its parent or any of its siblings. Similarly,
482 // when any of the item's descendants gets focus, the item constrains the tab
483 // focus chain and prevents tabbing outside.
488 // set true when this item does not expect events via a subscene delivery agent; false otherwise
490 // set true if this item or any child wants QQuickItemPrivate::transformChanged() to visit all children
491 // (e.g. when parent has ItemIsViewport and child has ItemObservesViewport)
493 quint32 inDestructor:1; // has entered ~QQuickItem
494
496 TransformOrigin = 0x00000001,
497 Transform = 0x00000002,
498 BasicTransform = 0x00000004,
499 Position = 0x00000008,
500 Size = 0x00000010,
501
502 ZValue = 0x00000020,
503 Content = 0x00000040,
504 Smooth = 0x00000080,
505 OpacityValue = 0x00000100,
506 ChildrenChanged = 0x00000200,
507 ChildrenStackingChanged = 0x00000400,
508 ParentChanged = 0x00000800,
509
510 Clip = 0x00001000,
511 Window = 0x00002000,
512
513 EffectReference = 0x00008000,
514 Visible = 0x00010000,
515 HideReference = 0x00020000,
516 Antialiasing = 0x00040000,
517 // When you add an attribute here, don't forget to update
518 // dirtyToString()
519
520 TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position |
522 ComplexTransformUpdateMask = Transform | Window,
523 ContentUpdateMask = Size | Content | Smooth | Window | Antialiasing,
524 ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Window
525 };
526
528 QString dirtyToString() const;
529 void dirty(DirtyType);
530 void addToDirtyList();
531 void removeFromDirtyList();
534
535 void setCulled(bool);
536
539 inline QSGContext *sceneGraphContext() const;
540 inline QSGRenderContext *sceneGraphRenderContext() const;
541
543
546 QList<QQuickItem *> paintOrderChildItems() const;
547 void addChild(QQuickItem *);
548 void removeChild(QQuickItem *);
549 void siblingOrderChanged();
550
551 inline void markSortedChildrenDirty(QQuickItem *child);
552
553 void refWindow(QQuickWindow *);
554 void derefWindow();
555
557 void updateSubFocusItem(QQuickItem *scope, bool focus);
558
559 QTransform windowToItemTransform() const;
560 QTransform itemToWindowTransform() const;
561 void itemToParentTransform(QTransform *) const;
562 QTransform globalToWindowTransform() const;
563 QTransform windowToGlobalTransform() const;
564
565 static bool focusNextPrev(QQuickItem *item, bool forward);
566 static QQuickItem *nextTabChildItem(const QQuickItem *item, int start);
567 static QQuickItem *prevTabChildItem(const QQuickItem *item, int start);
568 static QQuickItem *nextPrevItemInTabFocusChain(QQuickItem *item, bool forward);
569
570 static bool canAcceptTabFocus(QQuickItem *item);
571
572 void setX(qreal x) {q_func()->setX(x);}
573 void xChanged() {q_func()->xChanged();}
575 void setY(qreal y) {q_func()->setY(y);}
576 void yChanged() {q_func()->yChanged();}
578 void setWidth(qreal width) {q_func()->setWidth(width);}
579 void widthChanged() {q_func()->widthChanged();}
581 void setHeight(qreal height) {q_func()->setHeight(height);}
582 void heightChanged() {q_func()->heightChanged();}
586
587 bool widthValid() const { return widthValidFlag || (width.hasBinding() && !QQmlPropertyBinding::isUndefined(width.binding()) ); }
588 bool heightValid() const { return heightValidFlag || (height.hasBinding() && !QQmlPropertyBinding::isUndefined(height.binding()) ); }
589
591
593
594 inline qreal z() const { return extra.isAllocated()?extra->z:0; }
595 inline qreal scale() const { return extra.isAllocated()?extra->scale:1; }
596 inline qreal rotation() const { return extra.isAllocated()?extra->rotation:0; }
597 inline qreal opacity() const { return extra.isAllocated()?extra->opacity:1; }
598
599 void setAccessible();
600
601 virtual qreal getImplicitWidth() const;
602 virtual qreal getImplicitHeight() const;
603 virtual void implicitWidthChanged();
604 virtual void implicitHeightChanged();
605
606#if QT_CONFIG(accessibility)
607 QAccessible::Role effectiveAccessibleRole() const;
608private:
609 virtual QAccessible::Role accessibleRole() const;
610public:
611#endif
612
613 void setImplicitAntialiasing(bool antialiasing);
614
615 void resolveLayoutMirror();
616 void setImplicitLayoutMirror(bool mirror, bool inherit);
617 void setLayoutMirror(bool mirror);
618 bool isMirrored() const {
619 return effectiveLayoutMirror;
620 }
621
623 Q_Q(QQuickItem);
624 Q_EMIT q->childrenRectChanged(rect);
625 }
626
627 QPointF computeTransformOrigin() const;
628 virtual bool transformChanged(QQuickItem *transformedItem);
629
630 QPointF adjustedPosForTransform(const QPointF &centroid,
631 const QPointF &startPos, const QVector2D &activeTranslatation,
632 qreal startScale, qreal activeScale,
633 qreal startRotation, qreal activeRotation);
634
635 QQuickDeliveryAgent *deliveryAgent();
636 QQuickDeliveryAgentPrivate *deliveryAgentPrivate();
637 QQuickDeliveryAgent *ensureSubsceneDeliveryAgent();
638
639 void deliverKeyEvent(QKeyEvent *);
640 bool filterKeyEvent(QKeyEvent *, bool post);
641#if QT_CONFIG(im)
642 void deliverInputMethodEvent(QInputMethodEvent *);
643#endif
644 void deliverShortcutOverrideEvent(QKeyEvent *);
645
646 bool anyPointerHandlerWants(const QPointerEvent *event, const QEventPoint &point) const;
647 virtual bool handlePointerEvent(QPointerEvent *, bool avoidGrabbers = false);
648
649 virtual void setVisible(bool visible);
650
651 bool isTransparentForPositioner() const;
652 void setTransparentForPositioner(bool trans);
653
654 bool calcEffectiveVisible() const;
655 bool setEffectiveVisibleRecur(bool);
656 bool calcEffectiveEnable() const;
657 void setEffectiveEnableRecur(QQuickItem *scope, bool);
658
659
660 inline QSGTransformNode *itemNode();
661 inline QSGNode *childContainerNode();
662
663 /*
664 QSGNode order is:
665 - itemNode
666 - (opacityNode)
667 - (clipNode)
668 - (rootNode) (shader effect source's root node)
669 */
670
671 QSGOpacityNode *opacityNode() const { return extra.isAllocated()?extra->opacityNode:nullptr; }
672 QQuickDefaultClipNode *clipNode() const { return extra.isAllocated()?extra->clipNode:nullptr; }
673 QSGRootNode *rootNode() const { return extra.isAllocated()?extra->rootNode:nullptr; }
674
677
678 virtual QSGTransformNode *createTransformNode();
679
680 // A reference from an effect item means that this item is used by the effect, so
681 // it should insert a root node.
682 void refFromEffectItem(bool hide);
683 void recursiveRefFromEffectItem(int refs);
684 void derefFromEffectItem(bool unhide);
685
686 void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &);
687
688 virtual void mirrorChange() {}
689
690 void setHasCursorInChild(bool hasCursor);
691 void setHasHoverInChild(bool hasHover);
692#if QT_CONFIG(cursor)
693 QCursor effectiveCursor(const QQuickPointerHandler *handler) const;
694 QQuickPointerHandler *effectiveCursorHandler() const;
695#endif
696
697 virtual void updatePolish() { }
698 virtual void dumpItemTree(int indent) const;
699};
700
701Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ExtraDataTags)
702
703/*
704 Key filters can be installed on a QQuickItem, but not removed. Currently they
705 are only used by attached objects (which are only destroyed on Item
706 destruction), so this isn't a problem. If in future this becomes any form
707 of public API, they will have to support removal too.
708*/
710{
711public:
712 QQuickItemKeyFilter(QQuickItem * = nullptr);
713 virtual ~QQuickItemKeyFilter();
714
715 virtual void keyPressed(QKeyEvent *event, bool post);
716 virtual void keyReleased(QKeyEvent *event, bool post);
717#if QT_CONFIG(im)
718 virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
719 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
720#endif
721 virtual void shortcutOverrideEvent(QKeyEvent *event);
722 virtual void componentComplete();
723
725
726private:
727 QQuickItemKeyFilter *m_next;
728};
729
731{
732public:
736
743 bool leftSet : 1;
744 bool rightSet : 1;
745 bool upSet : 1;
746 bool downSet : 1;
747 bool tabSet : 1;
748 bool backtabSet : 1;
749};
750
751class Q_QUICK_PRIVATE_EXPORT QQuickKeyNavigationAttached : public QObject, public QQuickItemKeyFilter
752{
754 Q_DECLARE_PRIVATE(QQuickKeyNavigationAttached)
755
756 Q_PROPERTY(QQuickItem *left READ left WRITE setLeft NOTIFY leftChanged FINAL)
757 Q_PROPERTY(QQuickItem *right READ right WRITE setRight NOTIFY rightChanged FINAL)
758 Q_PROPERTY(QQuickItem *up READ up WRITE setUp NOTIFY upChanged FINAL)
759 Q_PROPERTY(QQuickItem *down READ down WRITE setDown NOTIFY downChanged FINAL)
760 Q_PROPERTY(QQuickItem *tab READ tab WRITE setTab NOTIFY tabChanged FINAL)
761 Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged FINAL)
762 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL)
763
764 QML_NAMED_ELEMENT(KeyNavigation)
766 QML_UNCREATABLE("KeyNavigation is only available via attached properties.")
768
769public:
771
772 QQuickItem *left() const;
773 void setLeft(QQuickItem *);
774 QQuickItem *right() const;
775 void setRight(QQuickItem *);
776 QQuickItem *up() const;
777 void setUp(QQuickItem *);
778 QQuickItem *down() const;
779 void setDown(QQuickItem *);
780 QQuickItem *tab() const;
781 void setTab(QQuickItem *);
782 QQuickItem *backtab() const;
783 void setBacktab(QQuickItem *);
784
785 enum Priority { BeforeItem, AfterItem };
786 Q_ENUM(Priority)
787 Priority priority() const;
788 void setPriority(Priority);
789
790 static QQuickKeyNavigationAttached *qmlAttachedProperties(QObject *);
791
795 void upChanged();
800
801private:
802 void keyPressed(QKeyEvent *event, bool post) override;
803 void keyReleased(QKeyEvent *event, bool post) override;
804 void setFocusNavigation(QQuickItem *currentItem, const char *dir,
806};
807
809{
811 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged FINAL)
813
814 QML_NAMED_ELEMENT(LayoutMirroring)
816 QML_UNCREATABLE("LayoutMirroring is only available via attached properties.")
818
819public:
820 explicit QQuickLayoutMirroringAttached(QObject *parent = nullptr);
821
822 bool enabled() const;
823 void setEnabled(bool);
824 void resetEnabled();
825
826 bool childrenInherit() const;
827 void setChildrenInherit(bool);
828
833private:
834 friend class QQuickItemPrivate;
835 QQuickItemPrivate *itemPrivate;
836};
837
839{
841 Q_PROPERTY(Qt::EnterKeyType type READ type WRITE setType NOTIFY typeChanged FINAL)
842
843 QML_NAMED_ELEMENT(EnterKey)
844 QML_UNCREATABLE("EnterKey is only available via attached properties")
847
848public:
849 explicit QQuickEnterKeyAttached(QObject *parent = nullptr);
850
851 Qt::EnterKeyType type() const;
853
857private:
858 friend class QQuickItemPrivate;
859 QQuickItemPrivate *itemPrivate;
860
861 Qt::EnterKeyType keyType;
862};
863
865{
866public:
869 {}
870
871 //loop detection
872 bool inPress:1;
873 bool inRelease:1;
874 bool inIM:1;
875
876 bool enabled : 1;
877
878 QQuickItem *imeItem = nullptr;
880 QQuickItem *item = nullptr;
882};
883
884class Q_QUICK_PRIVATE_EXPORT QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
885{
887 Q_DECLARE_PRIVATE(QQuickKeysAttached)
888
889 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
890 Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo FINAL)
891 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL)
892
895 QML_UNCREATABLE("Keys is only available via attached properties")
897
898public:
900 ~QQuickKeysAttached() override;
901
902 bool enabled() const { Q_D(const QQuickKeysAttached); return d->enabled; }
903 void setEnabled(bool enabled) {
905 if (enabled != d->enabled) {
906 d->enabled = enabled;
907 Q_EMIT enabledChanged();
908 }
909 }
910
911 enum Priority { BeforeItem, AfterItem};
912 Q_ENUM(Priority)
913 Priority priority() const;
914 void setPriority(Priority);
915
918 return QQmlListProperty<QQuickItem>(this, &(d->targets));
919 }
920
921 void componentComplete() override;
922
923 static QQuickKeysAttached *qmlAttachedProperties(QObject *);
924
941
948
971
972private:
973 void keyPressed(QKeyEvent *event, bool post) override;
974 void keyReleased(QKeyEvent *event, bool post) override;
975#if QT_CONFIG(im)
976 void inputMethodEvent(QInputMethodEvent *, bool post) override;
977 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
978#endif
979 void shortcutOverrideEvent(QKeyEvent *event) override;
980 static QByteArray keyToSignal(int key);
981
982 bool isConnected(const char *signalName) const;
983};
984
986{
987 return ((extra.tag().testFlag(LeftMouseButtonAccepted) ? Qt::LeftButton : Qt::MouseButton(0)) |
988 (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons{}));
989}
990
992{
994 return static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(window))->context->sceneGraphContext();
995}
996
998{
1000 return static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(window))->context;
1001}
1002
1004{
1005 // If sortedChildItems == &childItems then all in childItems have z == 0
1006 // and we don't need to invalidate if the changed item also has z == 0.
1007 if (child->z() != 0. || sortedChildItems != &childItems) {
1009 delete sortedChildItems;
1010 sortedChildItems = nullptr;
1011 }
1012}
1013
1015{
1016 return extra.isAllocated() ? QQuickItem::TransformOrigin(extra->origin)
1018}
1019
1021{
1022 if (!itemNodeInstance) {
1025#ifdef QSG_RUNTIME_DESCRIPTION
1026 Q_Q(QQuickItem);
1027 qsgnode_set_description(itemNodeInstance, QString::fromLatin1("QQuickItem(%1:%2)").arg(QString::fromLatin1(q->metaObject()->className())).arg(q->objectName()));
1028#endif
1029 }
1030 return itemNodeInstance;
1031}
1032
1034{
1035 if (rootNode())
1036 return rootNode();
1037 else if (clipNode())
1038 return clipNode();
1039 else if (opacityNode())
1040 return opacityNode();
1041 else
1042 return itemNode();
1043}
1044
1045Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes)
1047
1049
1050#if QT_CONFIG(quick_shadereffect)
1051QML_DECLARE_TYPE(QQuickItemLayer)
1052#endif
1057
1058#endif // QQUICKITEM_P_H
\inmodule QtCore
Definition qbytearray.h:57
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
\inmodule QtCore
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:624
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:153
\inmodule QtCore
Definition qobject.h:90
const QObjectList & children() const
Returns a list of child objects.
Definition qobject.h:171
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
\inmodule QtCore\reentrant
Definition qpoint.h:214
A base class for pointer events.
Definition qevent.h:73
\inmodule QtCore
Definition qpointer.h:18
The QQmlComponent class encapsulates a QML component definition.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
~QQuickContents() override
void calcGeometry(QQuickItem *changed=nullptr)
void itemChildRemoved(QQuickItem *, QQuickItem *) override
void itemChildAdded(QQuickItem *, QQuickItem *) override
QRectF rectF() const
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override
void itemDestroyed(QQuickItem *item) override
Qt::EnterKeyType type
void setType(Qt::EnterKeyType type)
static QQuickEnterKeyAttached * qmlAttachedProperties(QObject *)
virtual void itemParentChanged(QQuickItem *, QQuickItem *)
virtual void itemSiblingOrderChanged(QQuickItem *)
virtual void itemOpacityChanged(QQuickItem *)
virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
virtual void itemVisibilityChanged(QQuickItem *)
QQuickItem ** prevDirtyItem
QQuickAnchors * _anchors
quint32 replayingPressEvent
Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, y, &QQuickItemPrivate::setY, &QQuickItemPrivate::yChanged)
QLazilyAllocated< ExtraData, ExtraDataTags > extra
virtual void updatePolish()
void notifyChangeListeners(QQuickItemPrivate::ChangeTypes changeTypes, Fn &&function, Args &&...args)
Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, width, &QQuickItemPrivate::setWidth, &QQuickItemPrivate::widthChanged)
QSGOpacityNode * opacityNode() const
quint32 subtreeCursorEnabled
QQuickDefaultClipNode * clipNode() const
quint32 maybeHasSubsceneDeliveryAgent
void setX(qreal x)
QSGRenderContext * sceneGraphRenderContext() const
void setHeight(qreal height)
quint32 effectiveLayoutMirror
QSGTransformNode * itemNodeInstance
quint32 subtreeHoverEnabled
QPointer< QQuickItem > subFocusItem
QSGContext * sceneGraphContext() const
quint32 inheritMirrorFromItem
bool isMirrored() const
Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, x, &QQuickItemPrivate::setX, &QQuickItemPrivate::xChanged)
quint32 antialiasingValid
QList< QQuickItem * > * sortedChildItems
virtual void mirrorChange()
bool widthValid() const
QQuickStateGroup * _stateGroup
QVector< QQuickItemPrivate::ChangeListener > changeListeners
quint32 notifiedActiveFocus
QQuickItem * parentItem
QSGNode * childContainerNode()
QQuickItem * nextDirtyItem
quint32 filtersChildMouseEvents
qreal z() const
qreal rotation() const
quint32 inheritMirrorFromParent
quint32 subtreeTransformChangedEnabled
QList< QQuickTransform * > transforms
QQuickWindow * window
void setY(qreal y)
Qt::MouseButtons acceptedMouseButtons() const
qreal opacity() const
static const QQuickItemPrivate * get(const QQuickItem *item)
static void visibleChildren_append(QQmlListProperty< QQuickItem > *prop, QQuickItem *o)
QQuickItem::TransformOrigin origin() const
qreal scale() const
quint32 componentComplete
void markSortedChildrenDirty(QQuickItem *child)
quint32 inheritedLayoutMirror
QSGTransformNode * itemNode()
QSGRootNode * rootNode() const
void setWidth(qreal width)
bool heightValid() const
quint32 implicitAntialiasing
Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, height, &QQuickItemPrivate::setHeight, &QQuickItemPrivate::heightChanged)
virtual QSGTransformNode * createTransformNode()
static QQuickItemPrivate * get(QQuickItem *item)
QList< QQuickItem * > childItems
void emitChildrenRectChanged(const QRectF &rect)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
TransformOrigin
\variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::o...
Definition qquickitem.h:170
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:143
QPointer< QQuickItem > backtab
QList< QQuickItem * > targets
void digit0Pressed(QQuickKeyEvent *event)
void digit1Pressed(QQuickKeyEvent *event)
void digit5Pressed(QQuickKeyEvent *event)
void digit9Pressed(QQuickKeyEvent *event)
void digit6Pressed(QQuickKeyEvent *event)
void volumeDownPressed(QQuickKeyEvent *event)
void tabPressed(QQuickKeyEvent *event)
void cancelPressed(QQuickKeyEvent *event)
void deletePressed(QQuickKeyEvent *event)
void hangupPressed(QQuickKeyEvent *event)
void enterPressed(QQuickKeyEvent *event)
void escapePressed(QQuickKeyEvent *event)
void callPressed(QQuickKeyEvent *event)
void upPressed(QQuickKeyEvent *event)
QQmlListProperty< QQuickItem > forwardTo()
void yesPressed(QQuickKeyEvent *event)
void context2Pressed(QQuickKeyEvent *event)
void backPressed(QQuickKeyEvent *event)
void menuPressed(QQuickKeyEvent *event)
void setEnabled(bool enabled)
void flipPressed(QQuickKeyEvent *event)
void rightPressed(QQuickKeyEvent *event)
void asteriskPressed(QQuickKeyEvent *event)
void digit2Pressed(QQuickKeyEvent *event)
bool enabled() const
void numberSignPressed(QQuickKeyEvent *event)
void leftPressed(QQuickKeyEvent *event)
void noPressed(QQuickKeyEvent *event)
void volumeUpPressed(QQuickKeyEvent *event)
void context3Pressed(QQuickKeyEvent *event)
void returnPressed(QQuickKeyEvent *event)
void released(QQuickKeyEvent *event)
void pressed(QQuickKeyEvent *event)
void spacePressed(QQuickKeyEvent *event)
void shortcutOverride(QQuickKeyEvent *event)
void selectPressed(QQuickKeyEvent *event)
void digit3Pressed(QQuickKeyEvent *event)
void backtabPressed(QQuickKeyEvent *event)
void digit4Pressed(QQuickKeyEvent *event)
void context1Pressed(QQuickKeyEvent *event)
void digit7Pressed(QQuickKeyEvent *event)
void downPressed(QQuickKeyEvent *event)
void context4Pressed(QQuickKeyEvent *event)
void digit8Pressed(QQuickKeyEvent *event)
static QQuickLayoutMirroringAttached * qmlAttachedProperties(QObject *)
static QQuickTransformPrivate * get(QQuickTransform *transform)
QQuickTransformPrivate()
\qmltype Transform \instantiates QQuickTransform \inqmlmodule QtQuick
QList< QQuickItem * > items
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
Definition qrect.h:483
The QSGContext holds the scene graph entry points for one QML engine.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
@ OwnedByParent
Definition qsgnode.h:51
void setFlag(Flag, bool=true)
Sets the flag f on this node if enabled is true; otherwise clears the flag.
Definition qsgnode.cpp:584
The QSGOpacityNode class is used to change opacity of nodes.
Definition qsgnode.h:279
The QSGRootNode is the toplevel root of any scene graph.
Definition qsgnode.h:262
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:244
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5710
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:916
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
\inmodule QtCore
Definition qvariant.h:64
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
[Window class with invokable method]
Definition window.h:11
widget setFormat(format)
myinstance setPriority(MyClass::VeryHigh)
button setDown(true)
bool focus
[0]
QCursor cursor
employee setName("Richard Schmit")
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
InputMethodQuery
MouseButton
Definition qnamespace.h:55
@ LeftButton
Definition qnamespace.h:57
EnterKeyType
FocusReason
@ OtherFocusReason
static void * context
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
EGLOutputLayerEXT layer
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
#define Size(name)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *)
Definition qobject.cpp:4336
GLint GLint GLint GLint GLint x
[0]
GLsizei samples
GLenum mode
GLuint64 key
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLsizei GLenum GLenum * types
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLdouble GLdouble right
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLint GLsizei width
GLint left
GLenum type
GLint GLint bottom
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLuint name
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLuint GLenum GLenum transform
GLenum query
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLdouble s
[6]
Definition qopenglext.h:235
GLuint * states
static qreal component(const QPointF &point, unsigned int i)
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define QML_UNCREATABLE(REASON)
#define QML_ANONYMOUS
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ATTACHED(ATTACHED_TYPE)
QQuickAnchors * anchors(QQuickItem *item)
static QQuickItemPrivate::ChangeTypes changeTypes
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
void qsgnode_set_description(QSGNode *node, const QString &description)
Definition qsgnode.cpp:639
SSL_CTX int(*) void arg)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_SIGNALS
@ Q_PRIMITIVE_TYPE
Definition qtypeinfo.h:144
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:163
unsigned int quint32
Definition qtypes.h:45
unsigned long long quint64
Definition qtypes.h:56
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
#define enabled
QList< int > list
[14]
QSharedPointer< T > other(t)
[5]
QString dir
[11]
QGraphicsOpacityEffect * effect
the effect attached to this item
QGraphicsItem * item
edit hide()
QLayoutItem * child
[0]
QJSValueList args
QJSEngine engine
[0]
QQuickItemPrivate::ChangeTypes ChangeTypes
ChangeListener(QQuickItemChangeListener *l=nullptr, ChangeTypes t={ })
QQuickItemChangeListener * listener
bool operator==(const ChangeListener &other) const
ChangeListener(QQuickItemChangeListener *l, QQuickGeometryChange gt)
QQuickEnterKeyAttached * enterKeyAttached
QQuickScreenAttached * screenAttached
QPointer< QObject > mask
QVector< QQuickPointerHandler * > pointerHandlers
QQuickDefaultClipNode * clipNode
Qt::MouseButtons acceptedMouseButtons
QQuickItemKeyFilter * keyHandler
QQuickLayoutMirroringAttached * layoutDirectionAttached
Qt::MouseButtons acceptedMouseButtonsWithoutHandlers
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
\inmodule QtQuick
Definition qquickitem.h:158