Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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#include <QtCore/qpointer.h>
46
47#include <QtGui/private/qlayoutpolicy_p.h>
48
50
51class QNetworkReply;
57
59{
60public:
62 ~QQuickContents() override;
63
64 QRectF rectF() const { return m_contents; }
65
66 inline void calcGeometry(QQuickItem *changed = nullptr);
67 void complete();
68
69protected:
70 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override;
71 void itemDestroyed(QQuickItem *item) override;
72 void itemChildAdded(QQuickItem *, QQuickItem *) override;
73 void itemChildRemoved(QQuickItem *, QQuickItem *) override;
74 //void itemVisibilityChanged(QQuickItem *item)
75
76private:
77 bool calcHeight(QQuickItem *changed = nullptr);
78 bool calcWidth(QQuickItem *changed = nullptr);
79 void updateRect();
80
81 QQuickItem *m_item;
82 QRectF m_contents;
83};
84
86{
87 bool wChanged = calcWidth(changed);
88 bool hChanged = calcHeight(changed);
89 if (wChanged || hChanged)
90 updateRect();
91}
92
94{
95 Q_DECLARE_PUBLIC(QQuickTransform)
96public:
98
100
101 QList<QQuickItem *> items;
102};
103
104#if QT_CONFIG(quick_shadereffect)
105
106class Q_QUICK_EXPORT QQuickItemLayer : public QObject, public QQuickItemChangeListener
107{
109 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
110 Q_PROPERTY(QSize textureSize READ size WRITE setSize NOTIFY sizeChanged FINAL)
111 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged FINAL)
112 Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged FINAL)
113 Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged FINAL)
114 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged REVISION(6, 5) FINAL)
115 Q_PROPERTY(QQuickShaderEffectSource::WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged FINAL)
116 Q_PROPERTY(QQuickShaderEffectSource::Format format READ format WRITE setFormat NOTIFY formatChanged FINAL)
117 Q_PROPERTY(QByteArray samplerName READ name WRITE setName NOTIFY nameChanged FINAL)
118 Q_PROPERTY(QQmlComponent *effect READ effect WRITE setEffect NOTIFY effectChanged FINAL)
119 Q_PROPERTY(QQuickShaderEffectSource::TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged FINAL)
120 Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged FINAL)
123
124public:
125 QQuickItemLayer(QQuickItem *item);
126 ~QQuickItemLayer() override;
127
128 void classBegin();
129 void componentComplete();
130
131 bool enabled() const { return m_enabled; }
132 void setEnabled(bool enabled);
133
134 bool mipmap() const { return m_mipmap; }
135 void setMipmap(bool mipmap);
136
137 bool smooth() const { return m_smooth; }
138 void setSmooth(bool s);
139
140 bool live() const { return m_live; }
141 void setLive(bool live);
142
143 QSize size() const { return m_size; }
144 void setSize(const QSize &size);
145
146 QQuickShaderEffectSource::Format format() const { return m_format; }
148
149 QRectF sourceRect() const { return m_sourceRect; }
150 void setSourceRect(const QRectF &sourceRect);
151
152 QQuickShaderEffectSource::WrapMode wrapMode() const { return m_wrapMode; }
154
155 QByteArray name() const { return m_name; }
156 void setName(const QByteArray &name);
157
158 QQmlComponent *effect() const { return m_effectComponent; }
159 void setEffect(QQmlComponent *effect);
160
161 QQuickShaderEffectSource::TextureMirroring textureMirroring() const { return m_textureMirroring; }
162 void setTextureMirroring(QQuickShaderEffectSource::TextureMirroring mirroring);
163
164 int samples() const { return m_samples; }
165 void setSamples(int count);
166
167 QQuickShaderEffectSource *effectSource() const { return m_effectSource; }
168
169 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
170 void itemOpacityChanged(QQuickItem *) override;
171 void itemParentChanged(QQuickItem *, QQuickItem *) override;
172 void itemSiblingOrderChanged(QQuickItem *) override;
173 void itemVisibilityChanged(QQuickItem *) override;
174
175 void updateMatrix();
176 void updateGeometry();
177 void updateOpacity();
178 void updateZ();
179
181 void enabledChanged(bool enabled);
182 void sizeChanged(const QSize &size);
183 void mipmapChanged(bool mipmap);
184 void wrapModeChanged(QQuickShaderEffectSource::WrapMode mode);
185 void nameChanged(const QByteArray &name);
186 void effectChanged(QQmlComponent *component);
187 void smoothChanged(bool smooth);
188 void liveChanged(bool live);
189 void formatChanged(QQuickShaderEffectSource::Format format);
190 void sourceRectChanged(const QRectF &sourceRect);
191 void textureMirroringChanged(QQuickShaderEffectSource::TextureMirroring mirroring);
192 void samplesChanged(int count);
193
194private:
195 friend class QQuickTransformAnimatorJob;
196 friend class QQuickOpacityAnimatorJob;
197
198 void activate();
199 void deactivate();
200 void activateEffect();
201 void deactivateEffect();
202
203 QQuickItem *m_item;
204 bool m_enabled;
205 bool m_mipmap;
206 bool m_smooth;
207 bool m_live;
208 bool m_componentComplete;
211 QSize m_size;
212 QRectF m_sourceRect;
213 QByteArray m_name;
214 QQmlComponent *m_effectComponent;
215 QQuickItem *m_effect;
216 QQuickShaderEffectSource *m_effectSource;
218 int m_samples;
219};
220
221#endif
222
223class Q_QUICK_EXPORT QQuickItemPrivate
224 : public QObjectPrivate
225 , public QQuickPaletteProviderPrivateBase<QQuickItem, QQuickItemPrivate>
226{
227 Q_DECLARE_PUBLIC(QQuickItem)
228
229public:
230 static QQuickItemPrivate* get(QQuickItem *item) { return item->d_func(); }
231 static const QQuickItemPrivate* get(const QQuickItem *item) { return item->d_func(); }
232
234 ~QQuickItemPrivate() override;
235 void init(QQuickItem *parent);
236
237 QQmlListProperty<QObject> data();
238 QQmlListProperty<QObject> resources();
239 QQmlListProperty<QQuickItem> children();
240 QQmlListProperty<QQuickItem> visibleChildren();
241
242 QQmlListProperty<QQuickState> states();
243 QQmlListProperty<QQuickTransition> transitions();
244
245 QString state() const;
246 void setState(const QString &);
247
248 QQuickAnchorLine left() const;
249 QQuickAnchorLine right() const;
250 QQuickAnchorLine horizontalCenter() const;
251 QQuickAnchorLine top() const;
252 QQuickAnchorLine bottom() const;
253 QQuickAnchorLine verticalCenter() const;
254 QQuickAnchorLine baseline() const;
255
256#if QT_CONFIG(quick_shadereffect)
257 QQuickItemLayer *layer() const;
258#endif
259
260 void localizedTouchEvent(const QTouchEvent *event, bool isFiltering, QMutableTouchEvent *localized);
261 bool hasPointerHandlers() const;
262 bool hasEnabledHoverHandlers() const;
263 virtual void addPointerHandler(QQuickPointerHandler *h);
264 virtual void removePointerHandler(QQuickPointerHandler *h);
265
266 // data property
267 static void data_append(QQmlListProperty<QObject> *, QObject *);
268 static qsizetype data_count(QQmlListProperty<QObject> *);
269 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
270 static void data_clear(QQmlListProperty<QObject> *);
271 static void data_removeLast(QQmlListProperty<QObject> *);
272
273 // resources property
274 static QObject *resources_at(QQmlListProperty<QObject> *, qsizetype);
275 static void resources_append(QQmlListProperty<QObject> *, QObject *);
276 static qsizetype resources_count(QQmlListProperty<QObject> *);
277 static void resources_clear(QQmlListProperty<QObject> *);
278 static void resources_removeLast(QQmlListProperty<QObject> *);
279
280 // children property
281 static void children_append(QQmlListProperty<QQuickItem> *, QQuickItem *);
282 static qsizetype children_count(QQmlListProperty<QQuickItem> *);
283 static QQuickItem *children_at(QQmlListProperty<QQuickItem> *, qsizetype);
284 static void children_clear(QQmlListProperty<QQuickItem> *);
285 static void children_removeLast(QQmlListProperty<QQuickItem> *);
286
287 // visibleChildren property
288 static qsizetype visibleChildren_count(QQmlListProperty<QQuickItem> *prop);
289 static QQuickItem *visibleChildren_at(QQmlListProperty<QQuickItem> *prop, qsizetype index);
290
291 // transform property
292 static qsizetype transform_count(QQmlListProperty<QQuickTransform> *list);
293 static void transform_append(QQmlListProperty<QQuickTransform> *list, QQuickTransform *);
294 static QQuickTransform *transform_at(QQmlListProperty<QQuickTransform> *list, qsizetype);
295 static void transform_clear(QQmlListProperty<QQuickTransform> *list);
296
297 void _q_resourceObjectDeleted(QObject *);
298 quint64 _q_createJSWrapper(QQmlV4ExecutionEnginePtr engine);
299
301 Geometry = 0x01,
302 SiblingOrder = 0x02,
303 Visibility = 0x04,
304 Opacity = 0x08,
305 Destroyed = 0x10,
306 Parent = 0x20,
307 Children = 0x40,
308 Rotation = 0x80,
309 ImplicitWidth = 0x100,
310 ImplicitHeight = 0x200,
311 Enabled = 0x400,
312 Focus = 0x800,
313 AllChanges = 0xFFFFFFFF
314 };
315
316 Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
317
319 using ChangeTypes = QQuickItemPrivate::ChangeTypes;
320
322 : listener(l)
323 , types(t)
324 , gTypes(QQuickGeometryChange::All)
325 {}
326
328 : listener(l)
329 , types(Geometry)
330 , gTypes(gt)
331 {}
332
333 bool operator==(const ChangeListener &other) const
334 { return listener == other.listener && types == other.types; }
335
338 QQuickGeometryChange gTypes; //NOTE: not used for ==
339
340#ifndef QT_NO_DEBUG_STREAM
341 private:
343#endif // QT_NO_DEBUG_STREAM
344 };
345
346 // call QQuickItemChangeListener
347 template <typename Fn, typename ...Args>
348 void notifyChangeListeners(QQuickItemPrivate::ChangeTypes changeTypes, Fn &&function, Args &&...args)
349 {
350 if (changeListeners.isEmpty())
351 return;
352
353 const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
354 for (const QQuickItemPrivate::ChangeListener &change : listeners) {
355 if (change.types & changeTypes) {
356 if constexpr (std::is_member_function_pointer_v<Fn>)
357 (change.listener->*function)(args...);
358 else
359 function(change, args...);
360 }
361 }
362 }
363
364 struct ExtraData {
365 ExtraData();
366
371
377 QVector<QQuickPointerHandler *> pointerHandlers;
378#if QT_CONFIG(quick_shadereffect)
379 mutable QQuickItemLayer *layer;
380#endif
381#if QT_CONFIG(cursor)
383#endif
385
386 // these do not include child items
389 // updated recursively for child items as well
391 // Mask contains() method index
393
394 // Contains mask
395 QPointer<QObject> mask;
396
400 // subsceneDeliveryAgent is set only if this item is the root of a subscene, not on all items within.
401 QQuickDeliveryAgent *subsceneDeliveryAgent = nullptr;
402
404
405 // Although acceptedMouseButtons is inside ExtraData, we actually store
406 // the LeftButton flag in the extra.tag() bit. This is because it is
407 // extremely common to set acceptedMouseButtons to LeftButton, but very
408 // rare to use any of the other buttons.
409 Qt::MouseButtons acceptedMouseButtons;
411
412 uint origin:5; // QQuickItem::TransformOrigin
414
415 // 26 bits padding
416 };
417
419 NoTag = 0x1,
420 LeftMouseButtonAccepted = 0x2
421 };
422 Q_DECLARE_FLAGS(ExtraDataTags, ExtraDataTag)
423
424 QLazilyAllocated<ExtraData, ExtraDataTags> extra;
425 // If the mask is an Item, inform it that it's being used as a mask (true) or is no longer being used (false)
426 virtual void registerAsContainmentMask(QQuickItem * /* maskedItem */, bool /* set */) { }
427
428 QQuickAnchors *anchors() const;
430
431 inline Qt::MouseButtons acceptedMouseButtons() const;
432
433 QVector<QQuickItemPrivate::ChangeListener> changeListeners;
434
435 void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types);
436 void updateOrAddItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types);
437 void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types);
438 void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types);
439 void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types);
440
441 QQuickStateGroup *_states();
443
444 inline QQuickItem::TransformOrigin origin() const;
445
446 // Bit 0
457 // Bit 16
474 // Bit 32
481 // isTabFence: When true, the item acts as a fence within the tab focus chain.
482 // This means that the item and its children will be skipped from the tab focus
483 // chain when navigating from its parent or any of its siblings. Similarly,
484 // when any of the item's descendants gets focus, the item constrains the tab
485 // focus chain and prevents tabbing outside.
488 // Bit 40
491 // set true when this item does not expect events via a subscene delivery agent; false otherwise
493 // set true if this item or any child wants QQuickItemPrivate::transformChanged() to visit all children
494 // (e.g. when parent has ItemIsViewport and child has ItemObservesViewport)
496 quint32 inDestructor:1; // has entered ~QQuickItem
499 // Bit 53
500
502 TransformOrigin = 0x00000001,
503 Transform = 0x00000002,
504 BasicTransform = 0x00000004,
505 Position = 0x00000008,
506 Size = 0x00000010,
507
508 ZValue = 0x00000020,
509 Content = 0x00000040,
510 Smooth = 0x00000080,
511 OpacityValue = 0x00000100,
512 ChildrenChanged = 0x00000200,
513 ChildrenStackingChanged = 0x00000400,
514 ParentChanged = 0x00000800,
515
516 Clip = 0x00001000,
517 Window = 0x00002000,
518
519 EffectReference = 0x00008000,
520 Visible = 0x00010000,
521 HideReference = 0x00020000,
522 Antialiasing = 0x00040000,
523 // When you add an attribute here, don't forget to update
524 // dirtyToString()
525
526 TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position |
528 ComplexTransformUpdateMask = Transform | Window,
529 ContentUpdateMask = Size | Content | Smooth | Window | Antialiasing,
530 ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Window
531 };
532
534 QString dirtyToString() const;
535 void dirty(DirtyType);
536 void addToDirtyList();
537 void removeFromDirtyList();
540
541 void setCulled(bool);
542
545 inline QSGContext *sceneGraphContext() const;
546 inline QSGRenderContext *sceneGraphRenderContext() const;
547
549
550 QList<QQuickItem *> childItems;
551 mutable QList<QQuickItem *> *sortedChildItems;
552 QList<QQuickItem *> paintOrderChildItems() const;
553 void addChild(QQuickItem *);
554 void removeChild(QQuickItem *);
555 void siblingOrderChanged();
556
557 inline void markSortedChildrenDirty(QQuickItem *child);
558
559 void refWindow(QQuickWindow *);
560 void derefWindow();
561
562 QPointer<QQuickItem> subFocusItem;
563 void updateSubFocusItem(QQuickItem *scope, bool focus);
564
565 bool setFocusIfNeeded(QEvent::Type);
566 Qt::FocusReason lastFocusChangeReason() const;
567 void setLastFocusChangeReason(Qt::FocusReason reason);
568
569 QTransform windowToItemTransform() const;
570 QTransform itemToWindowTransform() const;
571 void itemToParentTransform(QTransform *) const;
572 QTransform globalToWindowTransform() const;
573 QTransform windowToGlobalTransform() const;
574
575 static bool focusNextPrev(QQuickItem *item, bool forward);
576 static QQuickItem *nextTabChildItem(const QQuickItem *item, int start);
577 static QQuickItem *prevTabChildItem(const QQuickItem *item, int start);
578 static QQuickItem *nextPrevItemInTabFocusChain(QQuickItem *item, bool forward, bool wrap = true);
579
580 static bool canAcceptTabFocus(QQuickItem *item);
581
582 void setX(qreal x) {q_func()->setX(x);}
583 void xChanged() {q_func()->xChanged();}
585 void setY(qreal y) {q_func()->setY(y);}
586 void yChanged() {q_func()->yChanged();}
588 void setWidth(qreal width) {q_func()->setWidth(width);}
589 void widthChanged() {q_func()->widthChanged();}
591 void setHeight(qreal height) {q_func()->setHeight(height);}
592 void heightChanged() {q_func()->heightChanged();}
596
597 bool widthValid() const { return widthValidFlag || (width.hasBinding() && !QQmlPropertyBinding::isUndefined(width.binding()) ); }
598 bool heightValid() const { return heightValidFlag || (height.hasBinding() && !QQmlPropertyBinding::isUndefined(height.binding()) ); }
599
601
602 QList<QQuickTransform *> transforms;
603
604 inline qreal z() const { return extra.isAllocated()?extra->z:0; }
605 inline qreal scale() const { return extra.isAllocated()?extra->scale:1; }
606 inline qreal rotation() const { return extra.isAllocated()?extra->rotation:0; }
607 inline qreal opacity() const { return extra.isAllocated()?extra->opacity:1; }
608
609 void setAccessible();
610
611 virtual qreal getImplicitWidth() const;
612 virtual qreal getImplicitHeight() const;
613 virtual void implicitWidthChanged();
614 virtual void implicitHeightChanged();
615
616#if QT_CONFIG(accessibility)
617 QAccessible::Role effectiveAccessibleRole() const;
618private:
619 virtual QAccessible::Role accessibleRole() const;
620public:
621#endif
622
623 void setImplicitAntialiasing(bool antialiasing);
624
625 void resolveLayoutMirror();
626 void setImplicitLayoutMirror(bool mirror, bool inherit);
627 void setLayoutMirror(bool mirror);
628 bool isMirrored() const {
629 return effectiveLayoutMirror;
630 }
631
633 Q_Q(QQuickItem);
634 Q_EMIT q->childrenRectChanged(rect);
635 }
636
637 QPointF computeTransformOrigin() const;
638 virtual bool transformChanged(QQuickItem *transformedItem);
639
640 QPointF adjustedPosForTransform(const QPointF &centroid,
641 const QPointF &startPos, const QVector2D &activeTranslatation,
642 qreal startScale, qreal activeScale,
643 qreal startRotation, qreal activeRotation);
644
645 QQuickDeliveryAgent *deliveryAgent();
646 QQuickDeliveryAgentPrivate *deliveryAgentPrivate();
647 QQuickDeliveryAgent *ensureSubsceneDeliveryAgent();
648
649 void deliverKeyEvent(QKeyEvent *);
650 bool filterKeyEvent(QKeyEvent *, bool post);
651#if QT_CONFIG(im)
652 void deliverInputMethodEvent(QInputMethodEvent *);
653#endif
654 void deliverShortcutOverrideEvent(QKeyEvent *);
655
656 void deliverPointerEvent(QEvent *);
657
658 bool anyPointerHandlerWants(const QPointerEvent *event, const QEventPoint &point) const;
659 virtual bool handlePointerEvent(QPointerEvent *, bool avoidGrabbers = false);
660
661 virtual void setVisible(bool visible);
662
663 bool isTransparentForPositioner() const;
664 void setTransparentForPositioner(bool trans);
665
666 bool calcEffectiveVisible() const;
667 bool setEffectiveVisibleRecur(bool);
668 bool calcEffectiveEnable() const;
669 void setEffectiveEnableRecur(QQuickItem *scope, bool);
670
671
672 inline QSGTransformNode *itemNode();
673 inline QSGNode *childContainerNode();
674
675 /*
676 QSGNode order is:
677 - itemNode
678 - (opacityNode)
679 - (clipNode)
680 - (rootNode) (shader effect source's root node)
681 */
682
683 QSGOpacityNode *opacityNode() const { return extra.isAllocated()?extra->opacityNode:nullptr; }
684 QQuickDefaultClipNode *clipNode() const { return extra.isAllocated()?extra->clipNode:nullptr; }
685 QSGRootNode *rootNode() const { return extra.isAllocated()?extra->rootNode:nullptr; }
686
689
690 virtual QSGTransformNode *createTransformNode();
691
692 // A reference from an effect item means that this item is used by the effect, so
693 // it should insert a root node.
694 void refFromEffectItem(bool hide);
695 void recursiveRefFromEffectItem(int refs);
696 void derefFromEffectItem(bool unhide);
697
698 void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &);
699
700 void enableSubtreeChangeNotificationsForParentHierachy();
701
702 virtual void mirrorChange() {}
703
704 void setHasCursorInChild(bool hasCursor);
705 void setHasHoverInChild(bool hasHover);
706#if QT_CONFIG(cursor)
707 QCursor effectiveCursor(const QQuickPointerHandler *handler) const;
708 QQuickPointerHandler *effectiveCursorHandler() const;
709#endif
710
711 virtual void updatePolish() { }
712 virtual void dumpItemTree(int indent) const;
713
714 QLayoutPolicy sizePolicy() const;
715 void setSizePolicy(const QLayoutPolicy::Policy &horizontalPolicy, const QLayoutPolicy::Policy &verticalPolicy);
717};
718
719Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ExtraDataTags)
720
721/*
722 Key filters can be installed on a QQuickItem, but not removed. Currently they
723 are only used by attached objects (which are only destroyed on Item
724 destruction), so this isn't a problem. If in future this becomes any form
725 of public API, they will have to support removal too.
726*/
728{
729public:
730 QQuickItemKeyFilter(QQuickItem * = nullptr);
731 virtual ~QQuickItemKeyFilter();
732
733 virtual void keyPressed(QKeyEvent *event, bool post);
734 virtual void keyReleased(QKeyEvent *event, bool post);
735#if QT_CONFIG(im)
736 virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
737 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
738#endif
739 virtual void shortcutOverrideEvent(QKeyEvent *event);
740 virtual void componentComplete();
741
743
744private:
745 QQuickItemKeyFilter *m_next;
746};
747
749{
750public:
754
755 QPointer<QQuickItem> left;
756 QPointer<QQuickItem> right;
757 QPointer<QQuickItem> up;
758 QPointer<QQuickItem> down;
759 QPointer<QQuickItem> tab;
760 QPointer<QQuickItem> backtab;
761 bool leftSet : 1;
762 bool rightSet : 1;
763 bool upSet : 1;
764 bool downSet : 1;
765 bool tabSet : 1;
766 bool backtabSet : 1;
767};
768
769class Q_QUICK_EXPORT QQuickKeyNavigationAttached : public QObject, public QQuickItemKeyFilter
770{
772 Q_DECLARE_PRIVATE(QQuickKeyNavigationAttached)
773
774 Q_PROPERTY(QQuickItem *left READ left WRITE setLeft NOTIFY leftChanged FINAL)
775 Q_PROPERTY(QQuickItem *right READ right WRITE setRight NOTIFY rightChanged FINAL)
776 Q_PROPERTY(QQuickItem *up READ up WRITE setUp NOTIFY upChanged FINAL)
777 Q_PROPERTY(QQuickItem *down READ down WRITE setDown NOTIFY downChanged FINAL)
778 Q_PROPERTY(QQuickItem *tab READ tab WRITE setTab NOTIFY tabChanged FINAL)
779 Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged FINAL)
780 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL)
781
782 QML_NAMED_ELEMENT(KeyNavigation)
784 QML_UNCREATABLE("KeyNavigation is only available via attached properties.")
786
787public:
789
790 QQuickItem *left() const;
791 void setLeft(QQuickItem *);
792 QQuickItem *right() const;
793 void setRight(QQuickItem *);
794 QQuickItem *up() const;
795 void setUp(QQuickItem *);
796 QQuickItem *down() const;
797 void setDown(QQuickItem *);
798 QQuickItem *tab() const;
799 void setTab(QQuickItem *);
800 QQuickItem *backtab() const;
801 void setBacktab(QQuickItem *);
802
803 enum Priority { BeforeItem, AfterItem };
804 Q_ENUM(Priority)
805 Priority priority() const;
806 void setPriority(Priority);
807
808 static QQuickKeyNavigationAttached *qmlAttachedProperties(QObject *);
809
813 void upChanged();
818
819private:
820 void keyPressed(QKeyEvent *event, bool post) override;
821 void keyReleased(QKeyEvent *event, bool post) override;
822 void setFocusNavigation(QQuickItem *currentItem, const char *dir,
824};
825
827{
831
832 QML_NAMED_ELEMENT(LayoutMirroring)
834 QML_UNCREATABLE("LayoutMirroring is only available via attached properties.")
836
837public:
839
840 bool enabled() const;
841 void setEnabled(bool);
842 void resetEnabled();
843
844 bool childrenInherit() const;
845 void setChildrenInherit(bool);
846
851private:
852 friend class QQuickItemPrivate;
853 QQuickItemPrivate *itemPrivate;
854};
855
857{
859 Q_PROPERTY(Qt::EnterKeyType type READ type WRITE setType NOTIFY typeChanged FINAL)
860
861 QML_NAMED_ELEMENT(EnterKey)
862 QML_UNCREATABLE("EnterKey is only available via attached properties")
865
866public:
868
869 Qt::EnterKeyType type() const;
870 void setType(Qt::EnterKeyType type);
871
874 void typeChanged();
875private:
876 friend class QQuickItemPrivate;
877 QQuickItemPrivate *itemPrivate;
878
879 Qt::EnterKeyType keyType;
880};
881
883{
884public:
886 : inPress(false), inRelease(false), inIM(false), enabled(true)
887 {}
888
889 //loop detection
890 bool inPress:1;
891 bool inRelease:1;
892 bool inIM:1;
893
894 bool enabled : 1;
895
896 QQuickItem *imeItem = nullptr;
897 QList<QQuickItem *> targets;
898 QQuickItem *item = nullptr;
900};
901
902class Q_QUICK_EXPORT QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
903{
905 Q_DECLARE_PRIVATE(QQuickKeysAttached)
906
907 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
908 Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo FINAL)
909 Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL)
910
913 QML_UNCREATABLE("Keys is only available via attached properties")
915
916public:
917 QQuickKeysAttached(QObject *parent=nullptr);
918 ~QQuickKeysAttached() override;
919
920 bool enabled() const { Q_D(const QQuickKeysAttached); return d->enabled; }
921 void setEnabled(bool enabled) {
923 if (enabled != d->enabled) {
924 d->enabled = enabled;
925 Q_EMIT enabledChanged();
926 }
927 }
928
929 enum Priority { BeforeItem, AfterItem};
930 Q_ENUM(Priority)
931 Priority priority() const;
932 void setPriority(Priority);
933
934 QQmlListProperty<QQuickItem> forwardTo() {
936 return QQmlListProperty<QQuickItem>(this, &(d->targets));
937 }
938
939 void componentComplete() override;
940
941 static QQuickKeysAttached *qmlAttachedProperties(QObject *);
942
959
966
989
990private:
991 void keyPressed(QKeyEvent *event, bool post) override;
992 void keyReleased(QKeyEvent *event, bool post) override;
993#if QT_CONFIG(im)
994 void inputMethodEvent(QInputMethodEvent *, bool post) override;
995 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
996#endif
997 void shortcutOverrideEvent(QKeyEvent *event) override;
998 static QByteArray keyToSignal(int key);
999
1000 bool isConnected(const char *signalName) const;
1001};
1002
1004{
1005 return ((extra.tag().testFlag(LeftMouseButtonAccepted) ? Qt::LeftButton : Qt::MouseButton(0)) |
1006 (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons{}));
1007}
1008
1010{
1012 return static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(window))->context->sceneGraphContext();
1013}
1014
1020
1022{
1023 // If sortedChildItems == &childItems then all in childItems have z == 0
1024 // and we don't need to invalidate if the changed item also has z == 0.
1025 if (child->z() != 0. || sortedChildItems != &childItems) {
1026 if (sortedChildItems != &childItems)
1027 delete sortedChildItems;
1028 sortedChildItems = nullptr;
1029 }
1030}
1031
1033{
1034 return extra.isAllocated() ? QQuickItem::TransformOrigin(extra->origin)
1036}
1037
1039{
1040 if (!itemNodeInstance) {
1041 itemNodeInstance = createTransformNode();
1042 itemNodeInstance->setFlag(QSGNode::OwnedByParent, false);
1043#ifdef QSG_RUNTIME_DESCRIPTION
1044 Q_Q(QQuickItem);
1045 qsgnode_set_description(itemNodeInstance, QString::fromLatin1("QQuickItem(%1:%2)").arg(QString::fromLatin1(q->metaObject()->className())).arg(q->objectName()));
1046#endif
1047 }
1048 return itemNodeInstance;
1049}
1050
1052{
1053 if (rootNode())
1054 return rootNode();
1055 else if (clipNode())
1056 return clipNode();
1057 else if (opacityNode())
1058 return opacityNode();
1059 else
1060 return itemNode();
1061}
1062
1063Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes)
1065
1067
1068#endif // QQUICKITEM_P_H
QList< QtAndroidInput::GenericMotionEventListener * > listeners
\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
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
The QKeyEvent class describes a key event.
Definition qevent.h:424
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore\reentrant
Definition qpoint.h:217
A base class for pointer events.
Definition qevent.h:73
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
QQuickContents(QQuickItem *item)
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
QQuickItem ** prevDirtyItem
QQuickAnchors * _anchors
quint32 replayingPressEvent
Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, y, &QQuickItemPrivate::setY, &QQuickItemPrivate::yChanged)
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
QLayoutPolicy szPolicy
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)
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)
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:63
TransformOrigin
\variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::o...
Definition qquickitem.h:171
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
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)
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:484
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
The QSGOpacityNode class is used to change opacity of nodes.
Definition qsgnode.h:276
The QSGRootNode is the toplevel root of any scene graph.
Definition qsgnode.h:259
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
\inmodule QtCore
Definition qvariant.h:65
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.
Definition qcompare.h:63
InputMethodQuery
MouseButton
Definition qnamespace.h:56
@ LeftButton
Definition qnamespace.h:58
EnterKeyType
FocusReason
@ OtherFocusReason
static void * context
static const QCssKnownValue properties[NumProperties - 1]
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
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
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLint GLsizei width
GLint left
GLenum type
GLint GLint bottom
GLuint start
GLuint name
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLuint GLenum GLenum transform
GLdouble s
[6]
Definition qopenglext.h:235
GLenum query
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint * states
static qreal component(const QPointF &point, unsigned int i)
#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:641
SSL_CTX int void * arg
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
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:157
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
unsigned int quint32
Definition qtypes.h:50
unsigned long long quint64
Definition qtypes.h:61
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
#define enabled
#define explicit
XID Window
QList< int > list
[14]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QSharedPointer< T > other(t)
[5]
QString dir
[11]
QGraphicsOpacityEffect * effect
the effect attached to this item
QGraphicsItem * item
edit hide()
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
widget setSizePolicy(policy)
manager post(request, myJson, this, [this](QRestReply &reply) { if(!reply.isSuccess()) { } if(std::optional json=reply.readJson()) { } })
proxy setType(QNetworkProxy::Socks5Proxy)
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
\inmodule QtQuick
Definition qquickitem.h:159