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.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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#include "qquickitem.h"
5
6#include "qquickwindow.h"
8#include <QtQml/qjsengine.h>
9#include "qquickwindow_p.h"
10
11#include "qquickevents_p_p.h"
12#include "qquickscreen_p.h"
13
14#include <QtQml/qqmlengine.h>
15#include <QtQml/qqmlcomponent.h>
16#include <QtQml/qqmlinfo.h>
17#include <QtGui/qpen.h>
18#include <QtGui/qguiapplication.h>
19#include <QtGui/qstylehints.h>
20#include <QtGui/private/qeventpoint_p.h>
21#include <QtGui/private/qguiapplication_p.h>
22#include <QtGui/private/qpointingdevice_p.h>
23#include <QtGui/qinputmethod.h>
24#include <QtCore/qcoreevent.h>
25#include <QtCore/private/qnumeric_p.h>
26#include <QtGui/qpa/qplatformtheme.h>
27#include <QtCore/qloggingcategory.h>
28#include <QtCore/private/qduplicatetracker_p.h>
29
30#include <private/qqmlglobal_p.h>
31#include <private/qqmlengine_p.h>
32#include <QtQuick/private/qquickstategroup_p.h>
33#include <private/qqmlopenmetaobject_p.h>
34#include <QtQuick/private/qquickstate_p.h>
35#include <private/qquickitem_p.h>
36#include <QtQuick/private/qquickaccessibleattached_p.h>
37#include <QtQuick/private/qquickhoverhandler_p.h>
38#include <QtQuick/private/qquickpointerhandler_p.h>
39#include <QtQuick/private/qquickpointerhandler_p_p.h>
40
41#include <private/qv4engine_p.h>
42#include <private/qv4object_p.h>
43#include <private/qv4qobjectwrapper_p.h>
44#include <private/qdebug_p.h>
45#include <private/qqmlvaluetypewrapper_p.h>
46
47#if QT_CONFIG(cursor)
48# include <QtGui/qcursor.h>
49#endif
50
51#include <QtCore/qpointer.h>
52
53#include <algorithm>
54#include <limits>
55
56// XXX todo Check that elements that create items handle memory correctly after visual ownership change
57
59
60Q_DECLARE_LOGGING_CATEGORY(lcMouseTarget)
64Q_LOGGING_CATEGORY(lcHandlerParent, "qt.quick.handler.parent")
65Q_LOGGING_CATEGORY(lcVP, "qt.quick.viewport")
66Q_LOGGING_CATEGORY(lcChangeListeners, "qt.quick.item.changelisteners")
67
68// after 100ms, a mouse/non-mouse cursor conflict is resolved in favor of the mouse handler
70
71void debugFocusTree(QQuickItem *item, QQuickItem *scope = nullptr, int depth = 1)
72{
73 if (lcFocus().isEnabled(QtDebugMsg)) {
74 qCDebug(lcFocus)
75 << QByteArray(depth, '\t').constData()
76 << (scope && QQuickItemPrivate::get(scope)->subFocusItem == item ? '*' : ' ')
77 << item->hasFocus()
78 << item->hasActiveFocus()
79 << item->isFocusScope()
80 << item;
81 const auto childItems = item->childItems();
82 for (QQuickItem *child : childItems) {
84 child,
85 item->isFocusScope() || !scope ? item : scope,
86 item->isFocusScope() || !scope ? depth + 1 : depth);
87 }
88 }
89}
90
92{
94 if (d->subFocusItem && d->window && d->flags & QQuickItem::ItemIsFocusScope)
95 QQuickWindowPrivate::get(d->window)->clearFocusInScope(item, d->subFocusItem, reason);
96 item->forceActiveFocus(reason);
97}
98
125
130
135
137{
138 Q_D(QQuickTransform);
139 for (int ii = 0; ii < d->items.size(); ++ii) {
141 p->transforms.removeOne(this);
143 }
144}
145
147{
148 Q_D(QQuickTransform);
149 for (int ii = 0; ii < d->items.size(); ++ii) {
152 }
153}
154
159
161{
162 QList<QQuickItem *> children = m_item->childItems();
163 for (int i = 0; i < children.size(); ++i) {
164 QQuickItem *child = children.at(i);
166 }
167}
168
169bool QQuickContents::calcHeight(QQuickItem *changed)
170{
171 qreal oldy = m_contents.y();
172 qreal oldheight = m_contents.height();
173
174 if (changed) {
175 qreal top = oldy;
176 qreal bottom = oldy + oldheight;
177 qreal y = changed->y();
178 if (y + changed->height() > bottom)
179 bottom = y + changed->height();
180 if (y < top)
181 top = y;
182 m_contents.setY(top);
183 m_contents.setHeight(bottom - top);
184 } else {
185 qreal top = std::numeric_limits<qreal>::max();
186 qreal bottom = -std::numeric_limits<qreal>::max();
187 QList<QQuickItem *> children = m_item->childItems();
188 for (int i = 0; i < children.size(); ++i) {
189 QQuickItem *child = children.at(i);
190 qreal y = child->y();
191 if (y + child->height() > bottom)
192 bottom = y + child->height();
193 if (y < top)
194 top = y;
195 }
196 if (!children.isEmpty())
197 m_contents.setY(top);
198 m_contents.setHeight(qMax(bottom - top, qreal(0.0)));
199 }
200
201 return (m_contents.height() != oldheight || m_contents.y() != oldy);
202}
203
204bool QQuickContents::calcWidth(QQuickItem *changed)
205{
206 qreal oldx = m_contents.x();
207 qreal oldwidth = m_contents.width();
208
209 if (changed) {
210 qreal left = oldx;
211 qreal right = oldx + oldwidth;
212 qreal x = changed->x();
213 if (x + changed->width() > right)
214 right = x + changed->width();
215 if (x < left)
216 left = x;
217 m_contents.setX(left);
218 m_contents.setWidth(right - left);
219 } else {
220 qreal left = std::numeric_limits<qreal>::max();
221 qreal right = -std::numeric_limits<qreal>::max();
222 QList<QQuickItem *> children = m_item->childItems();
223 for (int i = 0; i < children.size(); ++i) {
224 QQuickItem *child = children.at(i);
225 qreal x = child->x();
226 if (x + child->width() > right)
227 right = x + child->width();
228 if (x < left)
229 left = x;
230 }
231 if (!children.isEmpty())
232 m_contents.setX(left);
233 m_contents.setWidth(qMax(right - left, qreal(0.0)));
234 }
235
236 return (m_contents.width() != oldwidth || m_contents.x() != oldx);
237}
238
240{
241 QQuickItemPrivate::get(m_item)->addItemChangeListener(this, QQuickItemPrivate::Children);
242
243 QList<QQuickItem *> children = m_item->childItems();
244 for (int i = 0; i < children.size(); ++i) {
245 QQuickItem *child = children.at(i);
247 //###what about changes to visibility?
248 }
249 calcGeometry();
250}
251
252void QQuickContents::updateRect()
253{
254 QQuickItemPrivate::get(m_item)->emitChildrenRectChanged(rectF());
255}
256
258{
259 Q_UNUSED(changed);
260 bool wChanged = false;
261 bool hChanged = false;
262 //### we can only pass changed if the left edge has moved left, or the right edge has moved right
263 if (change.horizontalChange())
264 wChanged = calcWidth(/*changed*/);
265 if (change.verticalChange())
266 hChanged = calcHeight(/*changed*/);
267 if (wChanged || hChanged)
268 updateRect();
269}
270
277
284
291
293: m_processPost(false), m_next(nullptr)
294{
296 if (p) {
297 m_next = p->extra.value().keyHandler;
298 p->extra->keyHandler = this;
299 }
300}
301
305
307{
308 if (m_next) m_next->keyPressed(event, post);
309}
310
312{
313 if (m_next) m_next->keyReleased(event, post);
314}
315
316#if QT_CONFIG(im)
317void QQuickItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post)
318{
319 if (m_next)
320 m_next->inputMethodEvent(event, post);
321 else
322 event->ignore();
323}
324
325QVariant QQuickItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
326{
327 if (m_next) return m_next->inputMethodQuery(query);
328 return QVariant();
329}
330#endif // im
331
333{
334 if (m_next)
336 else
337 event->ignore();
338}
339
341{
342 if (m_next) m_next->componentComplete();
343}
436
442
444{
446 return d->left;
447}
448
450{
452 if (d->leftSet && d->left == i)
453 return;
454 d->leftSet = d->left != i;
455 d->left = i;
457 qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
458 if (other && !other->d_func()->rightSet){
459 other->d_func()->right = qobject_cast<QQuickItem*>(parent());
460 emit other->rightChanged();
461 }
463}
464
466{
468 return d->right;
469}
470
472{
474 if (d->rightSet && d->right == i)
475 return;
476 d->rightSet = d->right != i;
477 d->right = i;
479 qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
480 if (other && !other->d_func()->leftSet){
481 other->d_func()->left = qobject_cast<QQuickItem*>(parent());
482 emit other->leftChanged();
483 }
485}
486
488{
490 return d->up;
491}
492
494{
496 if (d->upSet && d->up == i)
497 return;
498 d->upSet = d->up != i;
499 d->up = i;
501 qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
502 if (other && !other->d_func()->downSet){
503 other->d_func()->down = qobject_cast<QQuickItem*>(parent());
504 emit other->downChanged();
505 }
506 emit upChanged();
507}
508
510{
512 return d->down;
513}
514
516{
518 if (d->downSet && d->down == i)
519 return;
520 d->downSet = d->down != i;
521 d->down = i;
523 qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
524 if (other && !other->d_func()->upSet) {
525 other->d_func()->up = qobject_cast<QQuickItem*>(parent());
526 emit other->upChanged();
527 }
529}
530
532{
534 return d->tab;
535}
536
538{
540 if (d->tabSet && d->tab == i)
541 return;
542 d->tabSet = d->tab != i;
543 d->tab = i;
545 qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
546 if (other && !other->d_func()->backtabSet) {
547 other->d_func()->backtab = qobject_cast<QQuickItem*>(parent());
548 emit other->backtabChanged();
549 }
551}
552
554{
556 return d->backtab;
557}
558
560{
562 if (d->backtabSet && d->backtab == i)
563 return;
564 d->backtabSet = d->backtab != i;
565 d->backtab = i;
567 qobject_cast<QQuickKeyNavigationAttached*>(qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(i));
568 if (other && !other->d_func()->tabSet) {
569 other->d_func()->tab = qobject_cast<QQuickItem*>(parent());
570 emit other->tabChanged();
571 }
573}
574
592
594{
595 bool processPost = order == AfterItem;
596 if (processPost != m_processPost) {
597 m_processPost = processPost;
599 }
600}
601
603{
605 event->ignore();
606
607 if (post != m_processPost) {
609 return;
610 }
611
612 bool mirror = false;
613 switch (event->key()) {
614 case Qt::Key_Left: {
615 if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
616 mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror;
617 QQuickItem* leftItem = mirror ? d->right : d->left;
618 if (leftItem) {
619 setFocusNavigation(leftItem, mirror ? "right" : "left", mirror ? Qt::TabFocusReason : Qt::BacktabFocusReason);
620 event->accept();
621 }
622 break;
623 }
624 case Qt::Key_Right: {
625 if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
626 mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror;
627 QQuickItem* rightItem = mirror ? d->left : d->right;
628 if (rightItem) {
629 setFocusNavigation(rightItem, mirror ? "left" : "right", mirror ? Qt::BacktabFocusReason : Qt::TabFocusReason);
630 event->accept();
631 }
632 break;
633 }
634 case Qt::Key_Up:
635 if (d->up) {
636 setFocusNavigation(d->up, "up", Qt::BacktabFocusReason);
637 event->accept();
638 }
639 break;
640 case Qt::Key_Down:
641 if (d->down) {
642 setFocusNavigation(d->down, "down", Qt::TabFocusReason);
643 event->accept();
644 }
645 break;
646 case Qt::Key_Tab:
647 if (d->tab) {
648 setFocusNavigation(d->tab, "tab", Qt::TabFocusReason);
649 event->accept();
650 }
651 break;
652 case Qt::Key_Backtab:
653 if (d->backtab) {
654 setFocusNavigation(d->backtab, "backtab", Qt::BacktabFocusReason);
655 event->accept();
656 }
657 break;
658 default:
659 break;
660 }
661
662 if (!event->isAccepted()) QQuickItemKeyFilter::keyPressed(event, post);
663}
664
666{
668 event->ignore();
669
670 if (post != m_processPost) {
672 return;
673 }
674
675 bool mirror = false;
676 switch (event->key()) {
677 case Qt::Key_Left:
678 if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
679 mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror;
680 if (mirror ? d->right : d->left)
681 event->accept();
682 break;
683 case Qt::Key_Right:
684 if (QQuickItem *parentItem = qobject_cast<QQuickItem*>(parent()))
685 mirror = QQuickItemPrivate::get(parentItem)->effectiveLayoutMirror;
686 if (mirror ? d->left : d->right)
687 event->accept();
688 break;
689 case Qt::Key_Up:
690 if (d->up) {
691 event->accept();
692 }
693 break;
694 case Qt::Key_Down:
695 if (d->down) {
696 event->accept();
697 }
698 break;
699 case Qt::Key_Tab:
700 if (d->tab) {
701 event->accept();
702 }
703 break;
704 case Qt::Key_Backtab:
705 if (d->backtab) {
706 event->accept();
707 }
708 break;
709 default:
710 break;
711 }
712
713 if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post);
714}
715
716void QQuickKeyNavigationAttached::setFocusNavigation(QQuickItem *currentItem, const char *dir,
717 Qt::FocusReason reason)
718{
719 QQuickItem *initialItem = currentItem;
720 bool isNextItem = false;
721 QVector<QQuickItem *> visitedItems;
722 do {
723 isNextItem = false;
724 if (currentItem->isVisible() && currentItem->isEnabled()) {
725 currentItem->forceActiveFocus(reason);
726 } else {
727 QObject *attached =
728 qmlAttachedPropertiesObject<QQuickKeyNavigationAttached>(currentItem, false);
729 if (attached) {
730 QQuickItem *tempItem = qvariant_cast<QQuickItem*>(attached->property(dir));
731 if (tempItem) {
732 visitedItems.append(currentItem);
733 currentItem = tempItem;
734 isNextItem = true;
735 }
736 }
737 }
738 }
739 while (currentItem != initialItem && isNextItem && !visitedItems.contains(currentItem));
740}
741
742struct SigMap {
743 int key;
744 const char *sig;
745};
746
747const SigMap sigMap[] = {
748 { Qt::Key_Left, "leftPressed" },
749 { Qt::Key_Right, "rightPressed" },
750 { Qt::Key_Up, "upPressed" },
751 { Qt::Key_Down, "downPressed" },
752 { Qt::Key_Tab, "tabPressed" },
753 { Qt::Key_Backtab, "backtabPressed" },
754 { Qt::Key_Asterisk, "asteriskPressed" },
755 { Qt::Key_NumberSign, "numberSignPressed" },
756 { Qt::Key_Escape, "escapePressed" },
757 { Qt::Key_Return, "returnPressed" },
758 { Qt::Key_Enter, "enterPressed" },
759 { Qt::Key_Delete, "deletePressed" },
760 { Qt::Key_Space, "spacePressed" },
761 { Qt::Key_Back, "backPressed" },
762 { Qt::Key_Cancel, "cancelPressed" },
763 { Qt::Key_Select, "selectPressed" },
764 { Qt::Key_Yes, "yesPressed" },
765 { Qt::Key_No, "noPressed" },
766 { Qt::Key_Context1, "context1Pressed" },
767 { Qt::Key_Context2, "context2Pressed" },
768 { Qt::Key_Context3, "context3Pressed" },
769 { Qt::Key_Context4, "context4Pressed" },
770 { Qt::Key_Call, "callPressed" },
771 { Qt::Key_Hangup, "hangupPressed" },
772 { Qt::Key_Flip, "flipPressed" },
773 { Qt::Key_Menu, "menuPressed" },
774 { Qt::Key_VolumeUp, "volumeUpPressed" },
775 { Qt::Key_VolumeDown, "volumeDownPressed" },
776 { 0, nullptr }
777};
778
779QByteArray QQuickKeysAttached::keyToSignal(int key)
780{
781 QByteArray keySignal;
782 if (key >= Qt::Key_0 && key <= Qt::Key_9) {
783 keySignal = "digit0Pressed";
784 keySignal[5] = '0' + (key - Qt::Key_0);
785 } else {
786 int i = 0;
787 while (sigMap[i].key && sigMap[i].key != key)
788 ++i;
789 keySignal = sigMap[i].sig;
790 }
791 return keySignal;
792}
793
794bool QQuickKeysAttached::isConnected(const char *signalName) const
795{
796 Q_D(const QQuickKeysAttached);
797 int signal_index = d->signalIndex(signalName);
798 return d->isSignalConnected(signal_index);
799}
800
1230: QObject(*(new QQuickKeysAttachedPrivate), parent),
1232{
1233 Q_D(QQuickKeysAttached);
1234 m_processPost = false;
1236 if (d->item != parent)
1237 qWarning() << "Could not attach Keys property to: " << parent << " is not an Item";
1238}
1239
1243
1248
1250{
1251 bool processPost = order == AfterItem;
1252 if (processPost != m_processPost) {
1253 m_processPost = processPost;
1255 }
1256}
1257
1259{
1260#if QT_CONFIG(im)
1261 Q_D(QQuickKeysAttached);
1262 if (d->item) {
1263 for (int ii = 0; ii < d->targets.size(); ++ii) {
1264 QQuickItem *targetItem = d->targets.at(ii);
1265 if (targetItem && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod)) {
1266 d->item->setFlag(QQuickItem::ItemAcceptsInputMethod);
1267 break;
1268 }
1269 }
1270 }
1271#endif
1272}
1273
1275{
1276 Q_D(QQuickKeysAttached);
1277 if (post != m_processPost || !d->enabled || d->inPress) {
1278 event->ignore();
1280 return;
1281 }
1282
1283 // first process forwards
1284 if (d->item && d->item->window()) {
1285 d->inPress = true;
1286 for (int ii = 0; ii < d->targets.size(); ++ii) {
1287 QQuickItem *i = d->targets.at(ii);
1288 if (i && i->isVisible()) {
1289 event->accept();
1291 if (event->isAccepted()) {
1292 d->inPress = false;
1293 return;
1294 }
1295 }
1296 }
1297 d->inPress = false;
1298 }
1299
1300 QQuickKeyEvent &ke = d->theKeyEvent;
1301 ke.reset(*event);
1302 QByteArray keySignal = keyToSignal(event->key());
1303 if (!keySignal.isEmpty()) {
1304 keySignal += "(QQuickKeyEvent*)";
1305 if (isConnected(keySignal)) {
1306 // If we specifically handle a key then default to accepted
1307 ke.setAccepted(true);
1308 int idx = QQuickKeysAttached::staticMetaObject.indexOfSignal(keySignal);
1309 metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QQuickKeyEvent*, &ke));
1310 }
1311 }
1312 if (!ke.isAccepted())
1313 emit pressed(&ke);
1314 event->setAccepted(ke.isAccepted());
1315
1316 if (!event->isAccepted()) QQuickItemKeyFilter::keyPressed(event, post);
1317}
1318
1320{
1321 Q_D(QQuickKeysAttached);
1322 if (post != m_processPost || !d->enabled || d->inRelease) {
1323 event->ignore();
1325 return;
1326 }
1327
1328 if (d->item && d->item->window()) {
1329 d->inRelease = true;
1330 for (int ii = 0; ii < d->targets.size(); ++ii) {
1331 QQuickItem *i = d->targets.at(ii);
1332 if (i && i->isVisible()) {
1333 event->accept();
1335 if (event->isAccepted()) {
1336 d->inRelease = false;
1337 return;
1338 }
1339 }
1340 }
1341 d->inRelease = false;
1342 }
1343
1344 QQuickKeyEvent &ke = d->theKeyEvent;
1345 ke.reset(*event);
1346 emit released(&ke);
1347 event->setAccepted(ke.isAccepted());
1348
1349 if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post);
1350}
1351
1352#if QT_CONFIG(im)
1353void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post)
1354{
1355 Q_D(QQuickKeysAttached);
1356 if (post == m_processPost && d->item && !d->inIM && d->item->window()) {
1357 d->inIM = true;
1358 for (int ii = 0; ii < d->targets.size(); ++ii) {
1359 QQuickItem *targetItem = d->targets.at(ii);
1360 if (targetItem && targetItem->isVisible() && (targetItem->flags() & QQuickItem::ItemAcceptsInputMethod)) {
1362 if (event->isAccepted()) {
1363 d->imeItem = targetItem;
1364 d->inIM = false;
1365 return;
1366 }
1367 }
1368 }
1369 d->inIM = false;
1370 }
1371 QQuickItemKeyFilter::inputMethodEvent(event, post);
1372}
1373
1374QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const
1375{
1376 Q_D(const QQuickKeysAttached);
1377 if (d->item) {
1378 for (int ii = 0; ii < d->targets.size(); ++ii) {
1379 QQuickItem *i = d->targets.at(ii);
1380 if (i && i->isVisible() && (i->flags() & QQuickItem::ItemAcceptsInputMethod) && i == d->imeItem) {
1381 //### how robust is i == d->imeItem check?
1382 QVariant v = i->inputMethodQuery(query);
1383 if (v.userType() == QMetaType::QRectF)
1384 v = d->item->mapRectFromItem(i, v.toRectF()); //### cost?
1385 return v;
1386 }
1387 }
1388 }
1389 return QQuickItemKeyFilter::inputMethodQuery(query);
1390}
1391#endif // im
1392
1394{
1395 Q_D(QQuickKeysAttached);
1396 QQuickKeyEvent &keyEvent = d->theKeyEvent;
1397 keyEvent.reset(*event);
1398 emit shortcutOverride(&keyEvent);
1399
1400 event->setAccepted(keyEvent.isAccepted());
1401}
1402
1407
1485{
1486 if (QQuickItem *item = qobject_cast<QQuickItem *>(parent))
1487 itemPrivate = QQuickItemPrivate::get(item);
1488 else if (QQuickWindow *window = qobject_cast<QQuickWindow *>(parent))
1489 itemPrivate = QQuickItemPrivate::get(window->contentItem());
1490
1491 if (itemPrivate)
1492 itemPrivate->extra.value().layoutDirectionAttached = this;
1493 else
1494 qmlWarning(parent) << tr("LayoutDirection attached property only works with Items and Windows");
1495}
1496
1501
1503{
1504 return itemPrivate ? itemPrivate->effectiveLayoutMirror : false;
1505}
1506
1508{
1509 if (!itemPrivate)
1510 return;
1511
1512 itemPrivate->isMirrorImplicit = false;
1513 if (enabled != itemPrivate->effectiveLayoutMirror) {
1514 itemPrivate->setLayoutMirror(enabled);
1515 if (itemPrivate->inheritMirrorFromItem)
1516 itemPrivate->resolveLayoutMirror();
1517 }
1518}
1519
1521{
1522 if (itemPrivate && !itemPrivate->isMirrorImplicit) {
1523 itemPrivate->isMirrorImplicit = true;
1524 itemPrivate->resolveLayoutMirror();
1525 }
1526}
1527
1529{
1530 return itemPrivate ? itemPrivate->inheritMirrorFromItem : false;
1531}
1532
1534 if (itemPrivate && childrenInherit != itemPrivate->inheritMirrorFromItem) {
1536 itemPrivate->resolveLayoutMirror();
1538 }
1539}
1540
1542{
1543 Q_Q(QQuickItem);
1544 if (QQuickItem *parentItem = q->parentItem()) {
1546 setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent);
1547 } else {
1549 }
1550}
1551
1552void QQuickItemPrivate::setImplicitLayoutMirror(bool mirror, bool inherit)
1553{
1554 inherit = inherit || inheritMirrorFromItem;
1556 mirror = effectiveLayoutMirror;
1557 if (mirror == inheritedLayoutMirror && inherit == inheritMirrorFromParent)
1558 return;
1559
1560 inheritMirrorFromParent = inherit;
1562
1563 if (isMirrorImplicit)
1564 setLayoutMirror(inherit ? inheritedLayoutMirror : false);
1565 for (int i = 0; i < childItems.size(); ++i) {
1566 if (QQuickItem *child = qmlobject_cast<QQuickItem *>(childItems.at(i))) {
1568 childPrivate->setImplicitLayoutMirror(inheritedLayoutMirror, inheritMirrorFromParent);
1569 }
1570 }
1571}
1572
1574{
1575 if (mirror != effectiveLayoutMirror) {
1576 effectiveLayoutMirror = mirror;
1577 if (_anchors) {
1579 anchor_d->fillChanged();
1580 anchor_d->centerInChanged();
1581 anchor_d->updateHorizontalAnchors();
1582 }
1583 mirrorChange();
1584 if (extra.isAllocated() && extra->layoutDirectionAttached) {
1585 emit extra->layoutDirectionAttached->enabledChanged();
1586 }
1587 }
1588}
1589
1638 : QObject(parent), itemPrivate(nullptr), keyType(Qt::EnterKeyDefault)
1639{
1640 if (QQuickItem *item = qobject_cast<QQuickItem*>(parent)) {
1641 itemPrivate = QQuickItemPrivate::get(item);
1642 itemPrivate->extra.value().enterKeyAttached = this;
1643 } else
1644 qmlWarning(parent) << tr("EnterKey attached property only works with Items");
1645}
1646
1651
1653{
1654 return keyType;
1655}
1656
1658{
1659 if (keyType != type) {
1660 keyType = type;
1661#if QT_CONFIG(im)
1662 if (itemPrivate && itemPrivate->activeFocus)
1664#endif
1665 typeChanged();
1666 }
1667}
1668
1670{
1671 isAccessible = true;
1672}
1673
1680{
1681 Q_Q(QQuickItem);
1682 Q_ASSERT(scope);
1683
1684 QQuickItemPrivate *scopePrivate = QQuickItemPrivate::get(scope);
1685
1686 QQuickItem *oldSubFocusItem = scopePrivate->subFocusItem;
1687 // Correct focus chain in scope
1688 if (oldSubFocusItem) {
1689 QQuickItem *sfi = scopePrivate->subFocusItem->parentItem();
1690 while (sfi && sfi != scope) {
1691 QQuickItemPrivate::get(sfi)->subFocusItem = nullptr;
1692 sfi = sfi->parentItem();
1693 }
1694 }
1695
1696 if (focus) {
1697 scopePrivate->subFocusItem = q;
1698 QQuickItem *sfi = scopePrivate->subFocusItem->parentItem();
1699 while (sfi && sfi != scope) {
1700 QQuickItemPrivate::get(sfi)->subFocusItem = q;
1701 sfi = sfi->parentItem();
1702 }
1703 } else {
1704 scopePrivate->subFocusItem = nullptr;
1705 }
1706}
1707
1708
1710{
1711 Q_Q(QQuickItem);
1712 const bool setFocusOnRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease();
1714
1715 switch (eventType) {
1718 case QEvent::TouchBegin:
1719 if (setFocusOnRelease)
1720 return false;
1721 break;
1723 case QEvent::TouchEnd:
1724 if (!setFocusOnRelease)
1725 return false;
1726 break;
1727 case QEvent::Wheel:
1729 break;
1730 default:
1731 break;
1732 }
1733
1734 if ((focusPolicy & policy) == policy) {
1736 return true;
1737 }
1738
1739 return false;
1740}
1741
1746
1748{
1749 if (focusReason == reason)
1750 return;
1751
1752 focusReason = reason;
1753}
1754
2354: QObject(*(new QQuickItemPrivate), parent)
2355{
2356 Q_D(QQuickItem);
2357 d->init(parent);
2358}
2359
2363: QObject(dd, parent)
2364{
2365 Q_D(QQuickItem);
2366 d->init(parent);
2367}
2368
2373{
2374 Q_D(QQuickItem);
2375 d->inDestructor = true;
2376
2377 if (d->windowRefCount > 1)
2378 d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
2379 if (d->parentItem)
2380 setParentItem(nullptr);
2381 else if (d->window)
2382 d->derefWindow();
2383
2384 for (QQuickItem *child : std::as_const(d->childItems))
2385 child->setParentItem(nullptr);
2386 d->childItems.clear();
2387
2388 d->notifyChangeListeners(QQuickItemPrivate::AllChanges, [this](const QQuickItemPrivate::ChangeListener &change){
2389 QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
2390 if (anchor)
2391 anchor->clearItem(this);
2392 });
2393 /*
2394 update item anchors that depended on us unless they are our child (and will also be destroyed),
2395 or our sibling, and our parent is also being destroyed.
2396 */
2397 d->notifyChangeListeners(QQuickItemPrivate::AllChanges, [this](const QQuickItemPrivate::ChangeListener &change){
2398 QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
2399 if (anchor && anchor->item && anchor->item->parentItem() && anchor->item->parentItem() != this)
2400 anchor->update();
2401 });
2403 d->changeListeners.clear();
2404
2405 /*
2406 Remove any references our transforms have to us, in case they try to
2407 remove themselves from our list of transforms when that list has already
2408 been destroyed after ~QQuickItem() has run.
2409 */
2410 for (int ii = 0; ii < d->transforms.size(); ++ii) {
2411 QQuickTransform *t = d->transforms.at(ii);
2413 tp->items.removeOne(this);
2414 }
2415
2416 if (d->extra.isAllocated()) {
2417 delete d->extra->contents; d->extra->contents = nullptr;
2418#if QT_CONFIG(quick_shadereffect)
2419 delete d->extra->layer; d->extra->layer = nullptr;
2420#endif
2421 }
2422
2423 delete d->_anchors; d->_anchors = nullptr;
2424 delete d->_stateGroup; d->_stateGroup = nullptr;
2425
2426 d->isQuickItem = false;
2427}
2428
2433{
2434 if (!item->window())
2435 return false;
2436
2437 if (item == item->window()->contentItem())
2438 return true;
2439
2440#if QT_CONFIG(accessibility)
2441 QAccessible::Role role = QQuickItemPrivate::get(item)->effectiveAccessibleRole();
2442 if (role == QAccessible::EditableText || role == QAccessible::Table || role == QAccessible::List) {
2443 return true;
2444 } else if (role == QAccessible::ComboBox || role == QAccessible::SpinBox) {
2445 if (QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(item))
2446 return iface->state().editable;
2447 }
2448#endif
2449
2450 QVariant editable = item->property("editable");
2451 if (editable.isValid())
2452 return editable.toBool();
2453
2454 QVariant readonly = item->property("readOnly");
2455 if (readonly.isValid() && !readonly.toBool() && item->property("text").isValid())
2456 return true;
2457
2458 return false;
2459}
2460
2472{
2474 const bool wrap = !window || window->isTopLevel();
2475
2477
2478 if (next == item)
2479 return false;
2480
2481 const auto reason = forward ? Qt::TabFocusReason : Qt::BacktabFocusReason;
2482
2483 if (!wrap && !next) {
2484 // Focus chain wrapped and we are not top-level window
2485 // Give focus to parent window
2488
2489
2490 qt_window_private(window->parent())->setFocusToTarget(
2493 reason);
2494 window->parent()->requestActivate();
2495 return true;
2496 }
2497
2498 next->forceActiveFocus(reason);
2499
2500 return true;
2501}
2502
2504{
2505 if (!item) {
2506 qWarning() << "QQuickItemPrivate::nextTabChildItem called with null item.";
2507 return nullptr;
2508 }
2509 const QList<QQuickItem *> &children = item->childItems();
2510 const int count = children.size();
2511 if (start < 0 || start >= count) {
2512 qWarning() << "QQuickItemPrivate::nextTabChildItem: Start index value out of range for item" << item;
2513 return nullptr;
2514 }
2515 while (start < count) {
2517 if (!child->d_func()->isTabFence)
2518 return child;
2519 ++start;
2520 }
2521 return nullptr;
2522}
2523
2525{
2526 if (!item) {
2527 qWarning() << "QQuickItemPrivate::prevTabChildItem called with null item.";
2528 return nullptr;
2529 }
2530 const QList<QQuickItem *> &children = item->childItems();
2531 const int count = children.size();
2532 if (start == -1)
2533 start = count - 1;
2534 if (start < 0 || start >= count) {
2535 qWarning() << "QQuickItemPrivate::prevTabChildItem: Start index value out of range for item" << item;
2536 return nullptr;
2537 }
2538 while (start >= 0) {
2540 if (!child->d_func()->isTabFence)
2541 return child;
2542 --start;
2543 }
2544 return nullptr;
2545}
2546
2548{
2549 Q_ASSERT(item);
2550 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: item:" << item << ", forward:" << forward;
2551
2552 if (!item->window())
2553 return item;
2554 const QQuickItem * const contentItem = item->window()->contentItem();
2555 if (!contentItem)
2556 return item;
2557
2558 bool all = QGuiApplication::styleHints()->tabFocusBehavior() == Qt::TabFocusAllControls;
2559
2560 QQuickItem *from = nullptr;
2561 bool isTabFence = item->d_func()->isTabFence;
2562 if (forward) {
2563 if (!isTabFence)
2564 from = item->parentItem();
2565 } else {
2566 if (!item->childItems().isEmpty())
2567 from = item->d_func()->childItems.constFirst();
2568 else if (!isTabFence)
2569 from = item->parentItem();
2570 }
2571 bool skip = false;
2572
2573 QQuickItem *startItem = item;
2574 QQuickItem *originalStartItem = startItem;
2575 // Protect from endless loop:
2576 // If we start on an invisible item we will not find it again.
2577 // If there is no other item which can become the focus item, we have a forever loop,
2578 // since the protection only works if we encounter the first item again.
2579 while (startItem && !startItem->isVisible()) {
2580 startItem = startItem->parentItem();
2581 }
2582 if (!startItem)
2583 return item;
2584
2585 QQuickItem *firstFromItem = from;
2586 QQuickItem *current = item;
2587 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
2588 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
2589 QDuplicateTracker<QQuickItem *> cycleDetector;
2590 do {
2591 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
2592 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
2593 skip = false;
2594 QQuickItem *last = current;
2595
2596 bool hasChildren = !current->childItems().isEmpty() && current->isEnabled() && current->isVisible();
2597 QQuickItem *firstChild = nullptr;
2598 QQuickItem *lastChild = nullptr;
2599 if (hasChildren) {
2600 firstChild = nextTabChildItem(current, 0);
2601 if (!firstChild)
2602 hasChildren = false;
2603 else
2604 lastChild = prevTabChildItem(current, -1);
2605 }
2606 isTabFence = current->d_func()->isTabFence;
2607 if (isTabFence && !hasChildren)
2608 return current;
2609
2610 // coming from parent: check children
2611 if (hasChildren && from == current->parentItem()) {
2612 if (forward) {
2613 current = firstChild;
2614 } else {
2615 current = lastChild;
2616 if (!current->childItems().isEmpty())
2617 skip = true;
2618 }
2619 } else if (hasChildren && forward && from != lastChild) {
2620 // not last child going forwards
2621 int nextChild = current->childItems().indexOf(from) + 1;
2622 current = nextTabChildItem(current, nextChild);
2623 } else if (hasChildren && !forward && from != firstChild) {
2624 // not first child going backwards
2625 int prevChild = current->childItems().indexOf(from) - 1;
2626 current = prevTabChildItem(current, prevChild);
2627 if (!current->childItems().isEmpty())
2628 skip = true;
2629 // back to the parent
2630 } else if (QQuickItem *parent = !isTabFence ? current->parentItem() : nullptr) {
2631 // we would evaluate the parent twice, thus we skip
2632 if (forward) {
2633 skip = true;
2634 } else if (QQuickItem *firstSibling = !forward ? nextTabChildItem(parent, 0) : nullptr) {
2635 if (last != firstSibling
2636 || (parent->isFocusScope() && parent->activeFocusOnTab() && parent->hasActiveFocus()))
2637 skip = true;
2638 }
2639 current = parent;
2640 } else if (hasChildren) {
2641 if (!wrap && (forward || firstFromItem != from)) {
2642 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain:"
2643 << "Focus chain about to wrap.";
2644 // If focus chain wraps, we should give the parent window
2645 // a chance to get focus, so we should stop here
2646 return nullptr;
2647 }
2648
2649 // Wrap around after checking all items forward
2650 if (forward) {
2651 current = firstChild;
2652 } else {
2653 current = lastChild;
2654 if (!current->childItems().isEmpty())
2655 skip = true;
2656 }
2657 }
2658 from = last;
2659 // if [from] item is equal to [firstFromItem], means we have traversed one path and
2660 // jump back to parent of the chain, and then we have to check whether we have
2661 // traversed all of the chain (by compare the [current] item with [startItem])
2662 // Since the [startItem] might be promoted to its parent if it is invisible,
2663 // we still have to check [current] item with original start item
2664 // We might also run into a cycle before we reach firstFromItem again
2665 // but note that we have to ignore current if we are meant to skip it
2666 if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
2667 (!skip && cycleDetector.hasSeen(current))) {
2668 // wrapped around, avoid endless loops
2669 if (item == contentItem) {
2670 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
2671 return item;
2672 } else {
2673 qCDebug(lcFocus) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return " << startItem;
2674 return startItem;
2675 }
2676 }
2677 if (!firstFromItem) {
2678 if (startItem->d_func()->isTabFence) {
2679 if (current == startItem)
2680 firstFromItem = from;
2681 } else { //start from root
2682 startItem = current;
2683 firstFromItem = from;
2684 }
2685 }
2686 } while (skip || !current->activeFocusOnTab() || !current->isEnabled() || !current->isVisible()
2687 || !(all || QQuickItemPrivate::canAcceptTabFocus(current)));
2688
2689 return current;
2690}
2691
2717{
2718 Q_D(const QQuickItem);
2719 return d->parentItem;
2720}
2721
2723{
2724 Q_D(QQuickItem);
2725 if (parentItem == d->parentItem)
2726 return;
2727
2728 if (parentItem) {
2729 QQuickItem *itemAncestor = parentItem;
2730 while (itemAncestor != nullptr) {
2731 if (Q_UNLIKELY(itemAncestor == this)) {
2732 qWarning() << "QQuickItem::setParentItem: Parent" << parentItem << "is already part of the subtree of" << this;
2733 return;
2734 }
2735 itemAncestor = itemAncestor->parentItem();
2736 }
2737 }
2738
2739 d->removeFromDirtyList();
2740
2741 QQuickItem *oldParentItem = d->parentItem;
2742 QQuickItem *scopeFocusedItem = nullptr;
2743
2744 if (oldParentItem) {
2745 QQuickItemPrivate *op = QQuickItemPrivate::get(oldParentItem);
2746
2747 QQuickItem *scopeItem = nullptr;
2748
2749 if (hasFocus() || op->subFocusItem == this)
2750 scopeFocusedItem = this;
2751 else if (!isFocusScope() && d->subFocusItem)
2752 scopeFocusedItem = d->subFocusItem;
2753
2754 if (scopeFocusedItem) {
2755 scopeItem = oldParentItem;
2756 while (!scopeItem->isFocusScope() && scopeItem->parentItem())
2757 scopeItem = scopeItem->parentItem();
2758 if (d->window) {
2759 d->deliveryAgentPrivate()->
2760 clearFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason,
2762 if (scopeFocusedItem != this)
2763 QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true);
2764 } else {
2765 QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, false);
2766 }
2767 }
2768
2769 const bool wasVisible = isVisible();
2770 op->removeChild(this);
2771 if (wasVisible && !op->inDestructor)
2772 emit oldParentItem->visibleChildrenChanged();
2773 } else if (d->window) {
2774 QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
2775 }
2776
2777 QQuickWindow *parentWindow = parentItem ? QQuickItemPrivate::get(parentItem)->window : nullptr;
2778 bool alreadyAddedChild = false;
2779 if (d->window == parentWindow) {
2780 // Avoid freeing and reallocating resources if the window stays the same.
2781 d->parentItem = parentItem;
2782 } else {
2783 auto oldParentItem = d->parentItem;
2784 d->parentItem = parentItem;
2785 if (d->parentItem) {
2786 QQuickItemPrivate::get(d->parentItem)->addChild(this);
2787 alreadyAddedChild = true;
2788 }
2789 if (d->window) {
2790 d->derefWindow();
2791 // as we potentially changed d->parentWindow above
2792 // the check in derefWindow could not work
2793 // thus, we redo it here with the old parent
2794 // Also, the window may have been deleted by derefWindow()
2795 if (!oldParentItem && d->window) {
2796 QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
2797 }
2798 }
2799 if (parentWindow)
2800 d->refWindow(parentWindow);
2801 }
2802
2804
2805 if (d->parentItem && !alreadyAddedChild)
2806 QQuickItemPrivate::get(d->parentItem)->addChild(this);
2807 else if (d->window && !alreadyAddedChild)
2808 QQuickWindowPrivate::get(d->window)->parentlessItems.insert(this);
2809
2810 d->setEffectiveVisibleRecur(d->calcEffectiveVisible());
2811 d->setEffectiveEnableRecur(nullptr, d->calcEffectiveEnable());
2812
2813 if (d->parentItem) {
2814 if (!scopeFocusedItem) {
2815 if (hasFocus())
2816 scopeFocusedItem = this;
2817 else if (!isFocusScope() && d->subFocusItem)
2818 scopeFocusedItem = d->subFocusItem;
2819 }
2820
2821 if (scopeFocusedItem) {
2822 // We need to test whether this item becomes scope focused
2823 QQuickItem *scopeItem = d->parentItem;
2824 while (!scopeItem->isFocusScope() && scopeItem->parentItem())
2825 scopeItem = scopeItem->parentItem();
2826
2827 if (QQuickItemPrivate::get(scopeItem)->subFocusItem
2828 || (!scopeItem->isFocusScope() && scopeItem->hasFocus())) {
2829 if (scopeFocusedItem != this)
2830 QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, false);
2831 QQuickItemPrivate::get(scopeFocusedItem)->focus = false;
2832 emit scopeFocusedItem->focusChanged(false);
2833 } else {
2834 if (d->window) {
2835 d->deliveryAgentPrivate()->
2836 setFocusInScope(scopeItem, scopeFocusedItem, Qt::OtherFocusReason,
2838 } else {
2839 QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, true);
2840 }
2841 }
2842 }
2843 }
2844
2845 if (d->parentItem)
2846 d->resolveLayoutMirror();
2847
2848 d->itemChange(ItemParentHasChanged, d->parentItem);
2849
2850 if (!d->inDestructor)
2851 emit parentChanged(d->parentItem);
2852 if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
2853 emit d->parentItem->visibleChildrenChanged();
2854}
2855
2874{
2875 Q_D(QQuickItem);
2876 if (!sibling || sibling == this || !d->parentItem || d->parentItem != QQuickItemPrivate::get(sibling)->parentItem) {
2877 qWarning().nospace() << "QQuickItem::stackBefore: Cannot stack "
2878 << this << " before " << sibling << ", which must be a sibling";
2879 return;
2880 }
2881
2882 QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(d->parentItem);
2883
2884 int myIndex = parentPrivate->childItems.lastIndexOf(this);
2885 int siblingIndex = parentPrivate->childItems.lastIndexOf(const_cast<QQuickItem *>(sibling));
2886
2887 Q_ASSERT(myIndex != -1 && siblingIndex != -1);
2888
2889 if (myIndex == siblingIndex - 1)
2890 return;
2891
2892 parentPrivate->childItems.move(myIndex, myIndex < siblingIndex ? siblingIndex - 1 : siblingIndex);
2893
2894 parentPrivate->markSortedChildrenDirty(this);
2895 parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged);
2896
2897 for (int ii = qMin(siblingIndex, myIndex); ii < parentPrivate->childItems.size(); ++ii)
2898 QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged();
2899}
2900
2919{
2920 Q_D(QQuickItem);
2921 if (!sibling || sibling == this || !d->parentItem || d->parentItem != QQuickItemPrivate::get(sibling)->parentItem) {
2922 qWarning().nospace() << "QQuickItem::stackAfter: Cannot stack "
2923 << this << " after " << sibling << ", which must be a sibling";
2924 return;
2925 }
2926
2927 QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(d->parentItem);
2928
2929 int myIndex = parentPrivate->childItems.lastIndexOf(this);
2930 int siblingIndex = parentPrivate->childItems.lastIndexOf(const_cast<QQuickItem *>(sibling));
2931
2932 Q_ASSERT(myIndex != -1 && siblingIndex != -1);
2933
2934 if (myIndex == siblingIndex + 1)
2935 return;
2936
2937 parentPrivate->childItems.move(myIndex, myIndex > siblingIndex ? siblingIndex + 1 : siblingIndex);
2938
2939 parentPrivate->markSortedChildrenDirty(this);
2940 parentPrivate->dirty(QQuickItemPrivate::ChildrenStackingChanged);
2941
2942 for (int ii = qMin(myIndex, siblingIndex + 1); ii < parentPrivate->childItems.size(); ++ii)
2943 QQuickItemPrivate::get(parentPrivate->childItems.at(ii))->siblingOrderChanged();
2944}
2945
2958{
2959 Q_D(const QQuickItem);
2960 return d->window;
2961}
2962
2964{
2965 return lhs->z() < rhs->z();
2966}
2967
2969{
2970 if (sortedChildItems)
2971 return *sortedChildItems;
2972
2973 // If none of the items have set Z then the paint order list is the same as
2974 // the childItems list. This is by far the most common case.
2975 bool haveZ = false;
2976 for (int i = 0; i < childItems.size(); ++i) {
2977 if (QQuickItemPrivate::get(childItems.at(i))->z() != 0.) {
2978 haveZ = true;
2979 break;
2980 }
2981 }
2982 if (haveZ) {
2983 sortedChildItems = new QList<QQuickItem*>(childItems);
2984 std::stable_sort(sortedChildItems->begin(), sortedChildItems->end(), itemZOrder_sort);
2985 return *sortedChildItems;
2986 }
2987
2988 sortedChildItems = const_cast<QList<QQuickItem*>*>(&childItems);
2989
2990 return childItems;
2991}
2992
2994{
2995 Q_Q(QQuickItem);
2996
2998
3000
3002
3003#if QT_CONFIG(cursor)
3004 // if the added child has a cursor and we do not currently have any children
3005 // with cursors, bubble the notification up
3006 if (childPrivate->subtreeCursorEnabled && !subtreeCursorEnabled)
3007 setHasCursorInChild(true);
3008#endif
3009
3010 if (childPrivate->subtreeHoverEnabled && !subtreeHoverEnabled)
3011 setHasHoverInChild(true);
3012
3013 childPrivate->recursiveRefFromEffectItem(extra.value().recursiveEffectRefCount);
3016
3018
3019 emit q->childrenChanged();
3020}
3021
3023{
3024 Q_Q(QQuickItem);
3025
3026 Q_ASSERT(child);
3027 if (!inDestructor) {
3028 // if we are getting destroyed, then the destructor will clear the list
3032 }
3033
3035
3036#if QT_CONFIG(cursor)
3037 // turn it off, if nothing else is using it
3038 if (childPrivate->subtreeCursorEnabled && subtreeCursorEnabled)
3039 setHasCursorInChild(false);
3040#endif
3041
3042 if (childPrivate->subtreeHoverEnabled && subtreeHoverEnabled)
3043 setHasHoverInChild(false);
3044
3045 childPrivate->recursiveRefFromEffectItem(-extra.value().recursiveEffectRefCount);
3046 if (!inDestructor) {
3049 }
3050
3052
3053 if (!inDestructor)
3054 emit q->childrenChanged();
3055}
3056
3058{
3059 // An item needs a window if it is referenced by another item which has a window.
3060 // Typically the item is referenced by a parent, but can also be referenced by a
3061 // ShaderEffect or ShaderEffectSource. 'windowRefCount' counts how many items with
3062 // a window is referencing this item. When the reference count goes from zero to one,
3063 // or one to zero, the window of this item is updated and propagated to the children.
3064 // As long as the reference count stays above zero, the window is unchanged.
3065 // refWindow() increments the reference count.
3066 // derefWindow() decrements the reference count.
3067
3068 Q_Q(QQuickItem);
3069 Q_ASSERT((window != nullptr) == (windowRefCount > 0));
3070 Q_ASSERT(c);
3071 if (++windowRefCount > 1) {
3072 if (c != window)
3073 qWarning("QQuickItem: Cannot use same item on different windows at the same time.");
3074 return; // Window already set.
3075 }
3076
3077 Q_ASSERT(window == nullptr);
3078 window = c;
3079
3080 if (polishScheduled)
3081 QQuickWindowPrivate::get(window)->itemsToPolish.append(q);
3082
3083 if (!parentItem)
3084 QQuickWindowPrivate::get(window)->parentlessItems.insert(q);
3085
3086 for (int ii = 0; ii < childItems.size(); ++ii) {
3088 QQuickItemPrivate::get(child)->refWindow(c);
3089 }
3090
3091 dirty(Window);
3092
3093 if (extra.isAllocated() && extra->screenAttached)
3094 extra->screenAttached->windowChanged(c);
3096}
3097
3099{
3100 Q_Q(QQuickItem);
3101 Q_ASSERT((window != nullptr) == (windowRefCount > 0));
3102
3103 if (!window)
3104 return; // This can happen when destroying recursive shader effect sources.
3105
3106 if (--windowRefCount > 0)
3107 return; // There are still other references, so don't set window to null yet.
3108
3109 q->releaseResources();
3112 if (polishScheduled)
3113 c->itemsToPolish.removeOne(q);
3114#if QT_CONFIG(cursor)
3115 if (c->cursorItem == q) {
3116 c->cursorItem = nullptr;
3117 window->unsetCursor();
3118 }
3119#endif
3120 if (itemNodeInstance)
3121 c->cleanup(itemNodeInstance);
3122 if (!parentItem)
3123 c->parentlessItems.remove(q);
3124
3125 window = nullptr;
3126
3127 itemNodeInstance = nullptr;
3128
3129 if (extra.isAllocated()) {
3130 extra->opacityNode = nullptr;
3131 extra->clipNode = nullptr;
3132 extra->rootNode = nullptr;
3133 }
3134
3135 paintNode = nullptr;
3136
3137 for (int ii = 0; ii < childItems.size(); ++ii) {
3138 if (QQuickItem *child = childItems.at(ii))
3139 QQuickItemPrivate::get(child)->derefWindow();
3140 }
3141
3142 dirty(Window);
3143
3144 if (extra.isAllocated() && extra->screenAttached)
3145 extra->screenAttached->windowChanged(nullptr);
3147}
3148
3149
3154{
3155 // XXX todo - optimize
3157}
3158
3163{
3164 // item's parent must not be itself, otherwise calling itemToWindowTransform() on it is infinite recursion
3166 QTransform rv = parentItem ? QQuickItemPrivate::get(parentItem)->itemToWindowTransform() : QTransform();
3168 return rv;
3169}
3170
3175{
3176 /* Read the current x and y values. As this is an internal method,
3177 we don't care about it being usable in bindings. Instead, we
3178 care about performance here, and thus we read the value with
3179 valueBypassingBindings. This avoids any checks whether we are
3180 in a binding (which sholdn't be too expensive, but can add up).
3181 */
3182
3183 qreal x = this->x.valueBypassingBindings();
3184 qreal y = this->y.valueBypassingBindings();
3185 if (x || y)
3186 t->translate(x, y);
3187
3188 if (!transforms.isEmpty()) {
3189 QMatrix4x4 m(*t);
3190 for (int ii = transforms.size() - 1; ii >= 0; --ii)
3191 transforms.at(ii)->applyTo(&m);
3192 *t = m.toTransform();
3193 }
3194
3195 if (scale() != 1. || rotation() != 0.) {
3197 t->translate(tp.x(), tp.y());
3198 t->scale(scale(), scale());
3199 t->rotate(rotation());
3200 t->translate(-tp.x(), -tp.y());
3201 }
3202}
3203
3208{
3209 if (Q_UNLIKELY(window == nullptr))
3210 return QTransform();
3211
3212 QPoint quickWidgetOffset;
3213 QWindow *renderWindow = QQuickRenderControl::renderWindowFor(window, &quickWidgetOffset);
3214 QPointF pos = (renderWindow ? renderWindow : window)->mapToGlobal(quickWidgetOffset);
3215 return QTransform::fromTranslate(pos.x(), pos.y());
3216}
3217
3222{
3223 if (Q_UNLIKELY(window == nullptr))
3224 return QTransform();
3225
3226 QPoint quickWidgetOffset;
3227 QWindow *renderWindow = QQuickRenderControl::renderWindowFor(window, &quickWidgetOffset);
3228 QPointF pos = (renderWindow ? renderWindow : window)->mapToGlobal(quickWidgetOffset);
3229 return QTransform::fromTranslate(-pos.x(), -pos.y());
3230}
3231
3242{
3243 Q_D(const QQuickItem);
3244 return d->componentComplete;
3245}
3246
3248 : _anchors(nullptr)
3249 , _stateGroup(nullptr)
3250 , flags(0)
3251 , widthValidFlag(false)
3252 , heightValidFlag(false)
3253 , componentComplete(true)
3254 , keepMouse(false)
3255 , keepTouch(false)
3256 , hoverEnabled(false)
3257 , smooth(true)
3258 , antialiasing(false)
3259 , focus(false)
3260 , activeFocus(false)
3261 , notifiedFocus(false)
3262 , notifiedActiveFocus(false)
3263 , filtersChildMouseEvents(false)
3264 , explicitVisible(true)
3265 , effectiveVisible(true)
3266 , explicitEnable(true)
3267 , effectiveEnable(true)
3268 , polishScheduled(false)
3269 , inheritedLayoutMirror(false)
3270 , effectiveLayoutMirror(false)
3271 , isMirrorImplicit(true)
3272 , inheritMirrorFromParent(false)
3273 , inheritMirrorFromItem(false)
3274 , isAccessible(false)
3275 , culled(false)
3276 , hasCursor(false)
3277 , subtreeCursorEnabled(false)
3278 , subtreeHoverEnabled(false)
3279 , activeFocusOnTab(false)
3280 , implicitAntialiasing(false)
3281 , antialiasingValid(false)
3282 , isTabFence(false)
3283 , replayingPressEvent(false)
3284 , touchEnabled(false)
3285 , hasCursorHandler(false)
3286 , maybeHasSubsceneDeliveryAgent(true)
3287 , subtreeTransformChangedEnabled(true)
3288 , inDestructor(false)
3289 , focusReason(Qt::OtherFocusReason)
3290 , focusPolicy(Qt::NoFocus)
3291 , dirtyAttributes(0)
3292 , nextDirtyItem(nullptr)
3293 , prevDirtyItem(nullptr)
3294 , window(nullptr)
3295 , windowRefCount(0)
3296 , parentItem(nullptr)
3297 , sortedChildItems(&childItems)
3298 , subFocusItem(nullptr)
3299 , x(0)
3300 , y(0)
3301 , width(0)
3302 , height(0)
3303 , implicitWidth(0)
3304 , implicitHeight(0)
3305 , baselineOffset(0)
3306 , itemNodeInstance(nullptr)
3307 , paintNode(nullptr)
3308 , szPolicy(QLayoutPolicy::Fixed, QLayoutPolicy::Fixed)
3309{
3310}
3311
3317
3319{
3320 Q_Q(QQuickItem);
3321
3322 isQuickItem = true;
3323
3324 baselineOffset = 0.0;
3325
3326 if (parent) {
3327 q->setParentItem(parent);
3329 setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent);
3330 }
3331}
3332
3337
3338void QQuickItemPrivate::setSizePolicy(const QLayoutPolicy::Policy& horizontalPolicy, const QLayoutPolicy::Policy& verticalPolicy)
3339{
3340 szPolicy.setHorizontalPolicy(horizontalPolicy);
3341 szPolicy.setVerticalPolicy(verticalPolicy);
3342}
3343
3344void QQuickItemPrivate::data_append(QQmlListProperty<QObject> *prop, QObject *o)
3345{
3346 if (!o)
3347 return;
3348
3349 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3350
3351 if (QQuickItem *item = qmlobject_cast<QQuickItem *>(o)) {
3352 item->setParentItem(that);
3353 } else if (QQuickPointerHandler *pointerHandler = qmlobject_cast<QQuickPointerHandler *>(o)) {
3354 if (pointerHandler->parent() != that) {
3355 qCDebug(lcHandlerParent) << "reparenting handler" << pointerHandler << ":" << pointerHandler->parent() << "->" << that;
3356 pointerHandler->setParent(that);
3357 }
3358 QQuickItemPrivate::get(that)->addPointerHandler(pointerHandler);
3359 } else {
3360 o->setParent(that);
3361 resources_append(prop, o);
3362 }
3363}
3364
3401{
3402 QQuickItem *item = static_cast<QQuickItem*>(property->object);
3404 QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
3405 QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
3406
3407 return resources_count(&resourcesProperty) + children_count(&childrenProperty);
3408}
3409
3411{
3412 QQuickItem *item = static_cast<QQuickItem*>(property->object);
3414 QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
3415 QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
3416
3417 qsizetype resourcesCount = resources_count(&resourcesProperty);
3418 if (i < resourcesCount)
3419 return resources_at(&resourcesProperty, i);
3420 const qsizetype j = i - resourcesCount;
3421 if (j < children_count(&childrenProperty))
3422 return children_at(&childrenProperty, j);
3423 return nullptr;
3424}
3425
3426void QQuickItemPrivate::data_clear(QQmlListProperty<QObject> *property)
3427{
3428 QQuickItem *item = static_cast<QQuickItem*>(property->object);
3430 QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
3431 QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
3432
3433 resources_clear(&resourcesProperty);
3434 children_clear(&childrenProperty);
3435}
3436
3437void QQuickItemPrivate::data_removeLast(QQmlListProperty<QObject> *property)
3438{
3439 QQuickItem *item = static_cast<QQuickItem*>(property->object);
3441
3442 QQmlListProperty<QQuickItem> childrenProperty = privateItem->children();
3443 if (children_count(&childrenProperty) > 0) {
3444 children_removeLast(&childrenProperty);
3445 return;
3446 }
3447
3448 QQmlListProperty<QObject> resourcesProperty = privateItem->resources();
3449 if (resources_count(&resourcesProperty) > 0)
3450 resources_removeLast(&resourcesProperty);
3451}
3452
3453QObject *QQuickItemPrivate::resources_at(QQmlListProperty<QObject> *prop, qsizetype index)
3454{
3455 QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
3456 return quickItemPrivate->extra.isAllocated() ? quickItemPrivate->extra->resourcesList.value(index) : 0;
3457}
3458
3459void QQuickItemPrivate::resources_append(QQmlListProperty<QObject> *prop, QObject *object)
3460{
3461 QQuickItem *quickItem = static_cast<QQuickItem *>(prop->object);
3462 QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(quickItem);
3463 if (!quickItemPrivate->extra.value().resourcesList.contains(object)) {
3464 quickItemPrivate->extra.value().resourcesList.append(object);
3465 qmlobject_connect(object, QObject, SIGNAL(destroyed(QObject*)),
3467 }
3468}
3469
3470qsizetype QQuickItemPrivate::resources_count(QQmlListProperty<QObject> *prop)
3471{
3472 QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
3473 return quickItemPrivate->extra.isAllocated() ? quickItemPrivate->extra->resourcesList.size() : 0;
3474}
3475
3476void QQuickItemPrivate::resources_clear(QQmlListProperty<QObject> *prop)
3477{
3478 QQuickItem *quickItem = static_cast<QQuickItem *>(prop->object);
3479 QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(quickItem);
3480 if (quickItemPrivate->extra.isAllocated()) {//If extra is not allocated resources is empty.
3481 for (QObject *object : std::as_const(quickItemPrivate->extra->resourcesList)) {
3482 qmlobject_disconnect(object, QObject, SIGNAL(destroyed(QObject*)),
3484 }
3485 quickItemPrivate->extra->resourcesList.clear();
3486 }
3487}
3488
3489void QQuickItemPrivate::resources_removeLast(QQmlListProperty<QObject> *prop)
3490{
3491 QQuickItem *quickItem = static_cast<QQuickItem *>(prop->object);
3492 QQuickItemPrivate *quickItemPrivate = QQuickItemPrivate::get(quickItem);
3493 if (quickItemPrivate->extra.isAllocated()) {//If extra is not allocated resources is empty.
3494 QList<QObject *> *resources = &quickItemPrivate->extra->resourcesList;
3495 if (resources->isEmpty())
3496 return;
3497
3498 qmlobject_disconnect(resources->last(), QObject, SIGNAL(destroyed(QObject*)),
3501 }
3502}
3503
3504QQuickItem *QQuickItemPrivate::children_at(QQmlListProperty<QQuickItem> *prop, qsizetype index)
3505{
3506 QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
3507 if (index >= p->childItems.size() || index < 0)
3508 return nullptr;
3509 else
3510 return p->childItems.at(index);
3511}
3512
3513void QQuickItemPrivate::children_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *o)
3514{
3515 if (!o)
3516 return;
3517
3518 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3519 if (o->parentItem() == that)
3520 o->setParentItem(nullptr);
3521
3522 o->setParentItem(that);
3523}
3524
3525qsizetype QQuickItemPrivate::children_count(QQmlListProperty<QQuickItem> *prop)
3526{
3527 QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
3528 return p->childItems.size();
3529}
3530
3531void QQuickItemPrivate::children_clear(QQmlListProperty<QQuickItem> *prop)
3532{
3533 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3535 while (!p->childItems.isEmpty())
3536 p->childItems.at(0)->setParentItem(nullptr);
3537}
3538
3539void QQuickItemPrivate::children_removeLast(QQmlListProperty<QQuickItem> *prop)
3540{
3541 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3543 if (!p->childItems.isEmpty())
3544 p->childItems.last()->setParentItem(nullptr);
3545}
3546
3547qsizetype QQuickItemPrivate::visibleChildren_count(QQmlListProperty<QQuickItem> *prop)
3548{
3549 QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
3550 qsizetype visibleCount = 0;
3551 qsizetype c = p->childItems.size();
3552 while (c--) {
3553 if (p->childItems.at(c)->isVisible()) visibleCount++;
3554 }
3555
3556 return visibleCount;
3557}
3558
3560{
3561 QQuickItemPrivate *p = QQuickItemPrivate::get(static_cast<QQuickItem *>(prop->object));
3562 const qsizetype childCount = p->childItems.size();
3563 if (index >= childCount || index < 0)
3564 return nullptr;
3565
3566 qsizetype visibleCount = -1;
3567 for (qsizetype i = 0; i < childCount; i++) {
3568 if (p->childItems.at(i)->isVisible()) visibleCount++;
3569 if (visibleCount == index) return p->childItems.at(i);
3570 }
3571 return nullptr;
3572}
3573
3574qsizetype QQuickItemPrivate::transform_count(QQmlListProperty<QQuickTransform> *prop)
3575{
3576 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3578
3579 return p->transforms.size();
3580}
3581
3583{
3584 Q_D(QQuickTransform);
3585 if (!item)
3586 return;
3587
3589
3590 if (!d->items.isEmpty() && !p->transforms.isEmpty() && p->transforms.contains(this)) {
3591 p->transforms.removeOne(this);
3592 p->transforms.append(this);
3593 } else {
3594 p->transforms.append(this);
3595 d->items.append(item);
3596 }
3597
3599}
3600
3602{
3603 Q_D(QQuickTransform);
3604 if (!item)
3605 return;
3606
3608
3609 if (!d->items.isEmpty() && !p->transforms.isEmpty() && p->transforms.contains(this)) {
3610 p->transforms.removeOne(this);
3611 p->transforms.prepend(this);
3612 } else {
3613 p->transforms.prepend(this);
3614 d->items.append(item);
3615 }
3616
3618}
3619
3620void QQuickItemPrivate::transform_append(QQmlListProperty<QQuickTransform> *prop, QQuickTransform *transform)
3621{
3622 if (!transform)
3623 return;
3624
3625 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3626 transform->appendToItem(that);
3627}
3628
3629QQuickTransform *QQuickItemPrivate::transform_at(QQmlListProperty<QQuickTransform> *prop, qsizetype idx)
3630{
3631 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3633
3634 if (idx < 0 || idx >= p->transforms.size())
3635 return nullptr;
3636 else
3637 return p->transforms.at(idx);
3638}
3639
3640void QQuickItemPrivate::transform_clear(QQmlListProperty<QQuickTransform> *prop)
3641{
3642 QQuickItem *that = static_cast<QQuickItem *>(prop->object);
3644
3645 for (qsizetype ii = 0; ii < p->transforms.size(); ++ii) {
3646 QQuickTransform *t = p->transforms.at(ii);
3648 tp->items.removeOne(that);
3649 }
3650
3651 p->transforms.clear();
3652
3654}
3655
3657{
3658 if (extra.isAllocated() && extra->resourcesList.contains(object))
3659 extra->resourcesList.removeAll(object);
3660}
3661
3757{
3758 if (!_anchors) {
3759 Q_Q(const QQuickItem);
3760 _anchors = new QQuickAnchors(const_cast<QQuickItem *>(q));
3761 if (!componentComplete)
3763 }
3764 return _anchors;
3765}
3766
3772
3773QQmlListProperty<QObject> QQuickItemPrivate::data()
3774{
3775 // Do not synthesize replace().
3776 // It would be extremely expensive and wouldn't work with most methods.
3777 QQmlListProperty<QObject> result;
3778 result.object = q_func();
3784 return result;
3785}
3786
3819{
3820 Q_D(QQuickItem);
3821 if (!d->extra.isAllocated() || !d->extra->contents) {
3822 d->extra.value().contents = new QQuickContents(this);
3823 if (d->componentComplete)
3824 d->extra->contents->complete();
3825 }
3826 return d->extra->contents->rectF();
3827}
3828
3832QList<QQuickItem *> QQuickItem::childItems() const
3833{
3834 Q_D(const QQuickItem);
3835 return d->childItems;
3836}
3837
3867{
3869}
3870
3872{
3873 if (clip() == c)
3874 return;
3875
3877 if (c)
3879 else if (!(inherits("QQuickFlickable") || inherits("QQuickRootItem")))
3880 setFlag(ItemIsViewport, false);
3881
3883}
3884
3894void QQuickItem::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
3895{
3896 Q_D(QQuickItem);
3897
3898 if (d->_anchors)
3899 QQuickAnchorsPrivate::get(d->_anchors)->updateMe();
3900
3901 QQuickGeometryChange change;
3902 change.setXChange(newGeometry.x() != oldGeometry.x());
3903 change.setYChange(newGeometry.y() != oldGeometry.y());
3904 change.setWidthChange(newGeometry.width() != oldGeometry.width());
3905 change.setHeightChange(newGeometry.height() != oldGeometry.height());
3906
3907 d->notifyChangeListeners(QQuickItemPrivate::Geometry, [&](const QQuickItemPrivate::ChangeListener &listener){
3908 if (change.matches(listener.gTypes))
3909 listener.listener->itemGeometryChanged(this, change, oldGeometry);
3910 });
3911
3912 // The notify method takes care of emitting the signal, and also notifies any
3913 // property observers.
3914 if (change.xChange())
3915 d->x.notify();
3916 if (change.yChange())
3917 d->y.notify();
3918 if (change.widthChange())
3919 d->width.notify();
3920 if (change.heightChange())
3921 d->height.notify();
3922#if QT_CONFIG(accessibility)
3923 if (QAccessible::isActive()) {
3924 if (QObject *acc = QQuickAccessibleAttached::findAccessible(this)) {
3925 QAccessibleEvent ev(acc, QAccessible::LocationChanged);
3926 QAccessible::updateAccessibility(&ev);
3927 }
3928 }
3929#endif
3930}
3931
3987{
3988 Q_UNUSED(updatePaintNodeData);
3989 delete oldNode;
3990 return nullptr;
3991}
3992
3993QQuickItem::UpdatePaintNodeData::UpdatePaintNodeData()
3994: transformNode(nullptr)
3995{
3996}
3997
4018
4023
4035{
4036}
4037
4038#define PRINT_LISTENERS() \
4039do { \
4040 qDebug().nospace() << q_func() << " (" << this \
4041 << ") now has the following listeners:"; \
4042 for (const auto &listener : std::as_const(changeListeners)) { \
4043 const auto objectPrivate = dynamic_cast<QObjectPrivate*>(listener.listener); \
4044 qDebug().nospace() << "- " << listener << " (QObject: " << (objectPrivate ? objectPrivate->q_func() : nullptr) << ")"; \
4045 } \
4046} \
4047while (false)
4048
4050{
4051 changeListeners.append(ChangeListener(listener, types));
4052
4053 if (lcChangeListeners().isDebugEnabled())
4055}
4056
4058{
4059 const ChangeListener changeListener(listener, types);
4060 const int index = changeListeners.indexOf(changeListener);
4061 if (index > -1)
4062 changeListeners[index].types = changeListener.types;
4063 else
4064 changeListeners.append(changeListener);
4065
4066 if (lcChangeListeners().isDebugEnabled())
4068}
4069
4071{
4072 ChangeListener change(listener, types);
4073 changeListeners.removeOne(change);
4074
4075 if (lcChangeListeners().isDebugEnabled())
4077}
4078
4081{
4082 ChangeListener change(listener, types);
4083 int index = changeListeners.indexOf(change);
4084 if (index > -1)
4085 changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes
4086 else
4087 changeListeners.append(change);
4088
4089 if (lcChangeListeners().isDebugEnabled())
4091}
4092
4095{
4096 ChangeListener change(listener, types);
4097 if (types.noChange()) {
4098 changeListeners.removeOne(change);
4099 } else {
4100 int index = changeListeners.indexOf(change);
4101 if (index > -1)
4102 changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes
4103 }
4104
4105 if (lcChangeListeners().isDebugEnabled())
4107}
4108
4117{
4118 event->ignore();
4119}
4120
4129{
4130 event->ignore();
4131}
4132
4133#if QT_CONFIG(im)
4141void QQuickItem::inputMethodEvent(QInputMethodEvent *event)
4142{
4143 event->ignore();
4144}
4145#endif // im
4146
4158{
4159 Q_D(QQuickItem);
4160#if QT_CONFIG(accessibility)
4161 if (QAccessible::isActive()) {
4162 if (QObject *acc = QQuickAccessibleAttached::findAccessible(this)) {
4163 QAccessibleEvent ev(acc, QAccessible::Focus);
4164 QAccessible::updateAccessibility(&ev);
4165 }
4166 }
4167#endif
4168 d->setLastFocusChangeReason(event->reason());
4169}
4170
4179{
4180 Q_D(QQuickItem);
4181 d->setLastFocusChangeReason(event->reason());
4182}
4183
4195{
4196 event->ignore();
4197}
4198
4211{
4212 event->ignore();
4213}
4214
4227{
4228 event->ignore();
4229}
4230
4239{
4240 event->ignore();
4241}
4242
4248{
4249 // XXX todo
4250}
4251
4257{
4258 // XXX todo
4259}
4260
4261#if QT_CONFIG(wheelevent)
4269void QQuickItem::wheelEvent(QWheelEvent *event)
4270{
4271 event->ignore();
4272}
4273#endif
4274
4283{
4284 event->ignore();
4285}
4286
4297{
4298 event->ignore();
4299}
4300
4311{
4312 event->ignore();
4313}
4314
4325{
4326 event->ignore();
4327}
4328
4329#if QT_CONFIG(quick_draganddrop)
4342void QQuickItem::dragEnterEvent(QDragEnterEvent *event)
4343{
4344 Q_UNUSED(event);
4345}
4346
4359void QQuickItem::dragMoveEvent(QDragMoveEvent *event)
4360{
4361 Q_UNUSED(event);
4362}
4363
4376void QQuickItem::dragLeaveEvent(QDragLeaveEvent *event)
4377{
4378 Q_UNUSED(event);
4379}
4380
4393void QQuickItem::dropEvent(QDropEvent *event)
4394{
4395 Q_UNUSED(event);
4396}
4397#endif // quick_draganddrop
4398
4430{
4431 Q_UNUSED(item);
4432 Q_UNUSED(event);
4433 return false;
4434}
4435
4436#if QT_CONFIG(im)
4445QVariant QQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
4446{
4447 Q_D(const QQuickItem);
4448 QVariant v;
4449
4450 switch (query) {
4451 case Qt::ImEnabled:
4452 v = (bool)(flags() & ItemAcceptsInputMethod);
4453 break;
4454 case Qt::ImHints:
4457 case Qt::ImFont:
4464 case Qt::ImReadOnly:
4465 if (d->extra.isAllocated() && d->extra->keyHandler)
4466 v = d->extra->keyHandler->inputMethodQuery(query);
4467 break;
4468 case Qt::ImEnterKeyType:
4469 if (d->extra.isAllocated() && d->extra->enterKeyAttached)
4470 v = d->extra->enterKeyAttached->type();
4471 break;
4473 if (!(!window() ||!isVisible() || qFuzzyIsNull(opacity()))) {
4474 QRectF rect = QRectF(0,0, width(), height());
4475 const QQuickItem *par = this;
4476 while (QQuickItem *parpar = par->parentItem()) {
4477 rect = parpar->mapRectFromItem(par, rect);
4478 if (parpar->clip())
4479 rect = rect.intersected(parpar->clipRect());
4480 par = parpar;
4481 }
4482 rect = par->mapRectToScene(rect);
4483 // once we have the rect in scene coordinates, clip to window
4484 rect = rect.intersected(QRectF(QPoint(0,0), window()->size()));
4485 // map it back to local coordinates
4487 }
4488 break;
4489 default:
4490 break;
4491 }
4492
4493 return v;
4494}
4495#endif // im
4496
4498{
4499 Q_Q(const QQuickItem);
4501}
4502
4504{
4505 Q_Q(const QQuickItem);
4507}
4508
4514
4516{
4517 Q_Q(const QQuickItem);
4518 return QQuickAnchorLine(const_cast<QQuickItem *>(q), QQuickAnchors::TopAnchor);
4519}
4520
4522{
4523 Q_Q(const QQuickItem);
4525}
4526
4532
4538
4562{
4563 Q_D(const QQuickItem);
4564 return d->baselineOffset;
4565}
4566
4568{
4569 Q_D(QQuickItem);
4570 if (offset == d->baselineOffset)
4571 return;
4572
4573 d->baselineOffset = offset;
4574
4575 d->notifyChangeListeners(QQuickItemPrivate::Geometry, [](const QQuickItemPrivate::ChangeListener &change){
4576 QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
4577 if (anchor)
4578 anchor->updateVerticalAnchors();
4579 });
4580
4581 if (d->_anchors && (d->_anchors->usedAnchors() & QQuickAnchors::BaselineAnchor))
4582 QQuickAnchorsPrivate::get(d->_anchors)->updateVerticalAnchors();
4583
4585}
4586
4587
4598{
4599 Q_D(QQuickItem);
4600 if (!(flags() & ItemHasContents)) {
4601#ifndef QT_NO_DEBUG
4602 qWarning() << metaObject()->className() << ": Update called for a item without content";
4603#endif
4604 return;
4605 }
4607}
4608
4618{
4619 Q_D(QQuickItem);
4620 if (!d->polishScheduled) {
4621 d->polishScheduled = true;
4622 if (d->window) {
4624 bool maybeupdate = p->itemsToPolish.isEmpty();
4625 p->itemsToPolish.append(this);
4626 if (maybeupdate) d->window->maybeUpdate();
4627 }
4628 }
4629}
4630
4646void QQuickItem::ensurePolished()
4647{
4648 updatePolish();
4649}
4650
4651#if QT_DEPRECATED_SINCE(6, 5)
4652static bool unwrapMapFromToFromItemArgs(QQmlV4FunctionPtr args, const QQuickItem *itemForWarning, const QString &functionNameForWarning,
4653 QQuickItem **itemObj, qreal *x, qreal *y, qreal *w, qreal *h, bool *isRect)
4654{
4655 QV4::ExecutionEngine *v4 = args->v4engine();
4656 if (args->length() != 2 && args->length() != 3 && args->length() != 5) {
4657 v4->throwTypeError();
4658 return false;
4659 }
4660
4661 QV4::Scope scope(v4);
4662 QV4::ScopedValue item(scope, (*args)[0]);
4663
4664 *itemObj = nullptr;
4665 if (!item->isNull()) {
4666 QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, item->as<QV4::QObjectWrapper>());
4667 if (qobjectWrapper)
4668 *itemObj = qobject_cast<QQuickItem*>(qobjectWrapper->object());
4669 }
4670
4671 if (!(*itemObj) && !item->isNull()) {
4672 qmlWarning(itemForWarning) << functionNameForWarning << " given argument \"" << item->toQStringNoThrow()
4673 << "\" which is neither null nor an Item";
4674 v4->throwTypeError();
4675 return false;
4676 }
4677
4678 *isRect = false;
4679
4680 if (args->length() == 2) {
4681 QV4::ScopedValue sv(scope, (*args)[1]);
4682 if (sv->isNull()) {
4683 qmlWarning(itemForWarning) << functionNameForWarning << "given argument \"" << sv->toQStringNoThrow()
4684 << "\" which is neither a point nor a rect";
4685 v4->throwTypeError();
4686 return false;
4687 }
4688 const QV4::Scoped<QV4::QQmlValueTypeWrapper> variantWrapper(scope, sv->as<QV4::QQmlValueTypeWrapper>());
4689 const QVariant v = variantWrapper ? variantWrapper->toVariant() : QVariant();
4690 if (v.canConvert<QPointF>()) {
4691 const QPointF p = v.toPointF();
4692 *x = p.x();
4693 *y = p.y();
4694 } else if (v.canConvert<QRectF>()) {
4695 const QRectF r = v.toRectF();
4696 *x = r.x();
4697 *y = r.y();
4698 *w = r.width();
4699 *h = r.height();
4700 *isRect = true;
4701 } else {
4702 qmlWarning(itemForWarning) << functionNameForWarning << "given argument \"" << sv->toQStringNoThrow()
4703 << "\" which is neither a point nor a rect";
4704 v4->throwTypeError();
4705 return false;
4706 }
4707 } else {
4708 QV4::ScopedValue vx(scope, (*args)[1]);
4709 QV4::ScopedValue vy(scope, (*args)[2]);
4710
4711 if (!vx->isNumber() || !vy->isNumber()) {
4712 v4->throwTypeError();
4713 return false;
4714 }
4715
4716 *x = vx->asDouble();
4717 *y = vy->asDouble();
4718
4719 if (args->length() > 3) {
4720 QV4::ScopedValue vw(scope, (*args)[3]);
4721 QV4::ScopedValue vh(scope, (*args)[4]);
4722 if (!vw->isNumber() || !vh->isNumber()) {
4723 v4->throwTypeError();
4724 return false;
4725 }
4726 *w = vw->asDouble();
4727 *h = vh->asDouble();
4728 *isRect = true;
4729 }
4730 }
4731
4732 return true;
4733}
4734#endif
4735
4754#if QT_DEPRECATED_SINCE(6, 5)
4759{
4760 QV4::ExecutionEngine *v4 = args->v4engine();
4761 QV4::Scope scope(v4);
4762
4763 qreal x, y, w, h;
4764 bool isRect;
4765 QQuickItem *itemObj;
4766 if (!unwrapMapFromToFromItemArgs(args, this, QStringLiteral("mapFromItem()"), &itemObj, &x, &y, &w, &h, &isRect))
4767 return;
4768
4769 const QVariant result = isRect ? QVariant(mapRectFromItem(itemObj, QRectF(x, y, w, h)))
4770 : QVariant(mapFromItem(itemObj, QPointF(x, y)));
4771
4772 QV4::ScopedObject rv(scope, v4->fromVariant(result));
4773 args->setReturnValue(rv.asReturnedValue());
4774}
4775#endif
4776
4781{
4782 Q_D(const QQuickItem);
4783
4784 // XXX todo - we need to be able to handle common parents better and detect
4785 // invalid cases
4786 if (ok) *ok = true;
4787
4788 QTransform t = d->itemToWindowTransform();
4789 if (other) t *= QQuickItemPrivate::get(other)->windowToItemTransform();
4790
4791 return t;
4792}
4793
4812#if QT_DEPRECATED_SINCE(6, 5)
4817{
4818 QV4::ExecutionEngine *v4 = args->v4engine();
4819 QV4::Scope scope(v4);
4820
4821 qreal x, y, w, h;
4822 bool isRect;
4823 QQuickItem *itemObj;
4824 if (!unwrapMapFromToFromItemArgs(args, this, QStringLiteral("mapToItem()"), &itemObj, &x, &y, &w, &h, &isRect))
4825 return;
4826
4827 const QVariant result = isRect ? QVariant(mapRectToItem(itemObj, QRectF(x, y, w, h)))
4828 : QVariant(mapToItem(itemObj, QPointF(x, y)));
4829
4830 QV4::ScopedObject rv(scope, v4->fromVariant(result));
4831 args->setReturnValue(rv.asReturnedValue());
4832}
4833
4834static bool unwrapMapFromToFromGlobalArgs(QQmlV4FunctionPtr args, const QQuickItem *itemForWarning, const QString &functionNameForWarning, qreal *x, qreal *y)
4835{
4836 QV4::ExecutionEngine *v4 = args->v4engine();
4837 if (args->length() != 1 && args->length() != 2) {
4838 v4->throwTypeError();
4839 return false;
4840 }
4841
4842 QV4::Scope scope(v4);
4843
4844 if (args->length() == 1) {
4845 QV4::ScopedValue sv(scope, (*args)[0]);
4846 if (sv->isNull()) {
4847 qmlWarning(itemForWarning) << functionNameForWarning << "given argument \"" << sv->toQStringNoThrow()
4848 << "\" which is not a point";
4849 v4->throwTypeError();
4850 return false;
4851 }
4852 const QV4::Scoped<QV4::QQmlValueTypeWrapper> variantWrapper(scope, sv->as<QV4::QQmlValueTypeWrapper>());
4853 const QVariant v = variantWrapper ? variantWrapper->toVariant() : QVariant();
4854 if (v.canConvert<QPointF>()) {
4855 const QPointF p = v.toPointF();
4856 *x = p.x();
4857 *y = p.y();
4858 } else {
4859 qmlWarning(itemForWarning) << functionNameForWarning << "given argument \"" << sv->toQStringNoThrow()
4860 << "\" which is not a point";
4861 v4->throwTypeError();
4862 return false;
4863 }
4864 } else {
4865 QV4::ScopedValue vx(scope, (*args)[0]);
4866 QV4::ScopedValue vy(scope, (*args)[1]);
4867
4868 if (!vx->isNumber() || !vy->isNumber()) {
4869 v4->throwTypeError();
4870 return false;
4871 }
4872
4873 *x = vx->asDouble();
4874 *y = vy->asDouble();
4875 }
4876
4877 return true;
4878}
4879
4892void QQuickItem::mapFromGlobal(QQmlV4FunctionPtr args) const
4893{
4894 QV4::ExecutionEngine *v4 = args->v4engine();
4895 QV4::Scope scope(v4);
4896
4897 qreal x, y;
4898 if (!unwrapMapFromToFromGlobalArgs(args, this, QStringLiteral("mapFromGlobal()"), &x, &y))
4899 return;
4900
4901 QVariant result = mapFromGlobal(QPointF(x, y));
4902
4903 QV4::ScopedObject rv(scope, v4->fromVariant(result));
4904 args->setReturnValue(rv.asReturnedValue());
4905}
4906#endif
4907
4918#if QT_DEPRECATED_SINCE(6, 5)
4922void QQuickItem::mapToGlobal(QQmlV4FunctionPtr args) const
4923{
4924 QV4::ExecutionEngine *v4 = args->v4engine();
4925 QV4::Scope scope(v4);
4926
4927 qreal x, y;
4928 if (!unwrapMapFromToFromGlobalArgs(args, this, QStringLiteral("mapFromGlobal()"), &x, &y))
4929 return;
4930
4931 QVariant result = mapToGlobal(QPointF(x, y));
4932
4933 QV4::ScopedObject rv(scope, v4->fromVariant(result));
4934 args->setReturnValue(rv.asReturnedValue());
4935}
4936#endif
4937
4968
4995{
4996 setFocus(true, reason);
4998 QQuickItem *scope = nullptr;
4999 while (parent) {
5001 parent->setFocus(true, reason);
5002 if (!scope)
5003 scope = parent;
5004 }
5006 }
5007}
5008
5026QQuickItem *QQuickItem::nextItemInFocusChain(bool forward)
5027{
5029}
5030
5046{
5047 const QList<QQuickItem *> children = childItems();
5048 for (int i = children.size()-1; i >= 0; --i) {
5050 // Map coordinates to the child element's coordinate space
5051 QPointF point = mapToItem(child, QPointF(x, y));
5052 if (child->isVisible() && child->contains(point))
5053 return child;
5054 }
5055 return nullptr;
5056}
5057
5099void QQuickItem::dumpItemTree() const
5100{
5101 Q_D(const QQuickItem);
5102 d->dumpItemTree(0);
5103}
5104
5106{
5107 Q_Q(const QQuickItem);
5108
5109 const auto indentStr = QString(indent * 4, QLatin1Char(' '));
5110 qDebug().nospace().noquote() << indentStr <<
5111#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
5112 const_cast<QQuickItem *>(q);
5113#else
5114 q;
5115#endif
5116 if (extra.isAllocated()) {
5117 for (const auto handler : extra->pointerHandlers)
5118 qDebug().nospace().noquote() << indentStr << u" \u26ee " << handler;
5119 }
5120 for (const QQuickItem *ch : childItems) {
5121 auto itemPriv = QQuickItemPrivate::get(ch);
5122 itemPriv->dumpItemTree(indent + 1);
5123 }
5124}
5125
5126QQmlListProperty<QObject> QQuickItemPrivate::resources()
5127{
5128 // Do not synthesize replace().
5129 // It would be extremely expensive and wouldn't work with most methods.
5130 QQmlListProperty<QObject> result;
5131 result.object = q_func();
5137 return result;
5138}
5139
5157QQmlListProperty<QQuickItem> QQuickItemPrivate::children()
5158{
5159 // Do not synthesize replace().
5160 // It would be extremely expensive and wouldn't work with most methods.
5161 QQmlListProperty<QQuickItem> result;
5162 result.object = q_func();
5168 return result;
5169}
5170
5181QQmlListProperty<QQuickItem> QQuickItemPrivate::visibleChildren()
5182{
5183 return QQmlListProperty<QQuickItem>(q_func(),
5184 nullptr,
5187
5188}
5189
5230QQmlListProperty<QQuickState> QQuickItemPrivate::states()
5231{
5232 return _states()->statesProperty();
5233}
5234
5267QQmlListProperty<QQuickTransition> QQuickItemPrivate::transitions()
5268{
5269 return _states()->transitionsProperty();
5270}
5271
5273{
5274 if (!_stateGroup)
5275 return QString();
5276 else
5277 return _stateGroup->state();
5278}
5279
5284
5308{
5309 Q_D(const QQuickItem);
5310 return d->state();
5311}
5312
5314{
5315 Q_D(QQuickItem);
5316 d->setState(state);
5317}
5318
5332QQmlListProperty<QQuickTransform> QQuickItem::transform()
5333{
5334 return QQmlListProperty<QQuickTransform>(this, nullptr, QQuickItemPrivate::transform_append,
5338}
5339
5346{
5347 Q_D(QQuickItem);
5348 d->componentComplete = false;
5349 if (d->_stateGroup)
5350 d->_stateGroup->classBegin();
5351 if (d->_anchors)
5352 d->_anchors->classBegin();
5353#if QT_CONFIG(quick_shadereffect)
5354 if (d->extra.isAllocated() && d->extra->layer)
5355 d->extra->layer->classBegin();
5356#endif
5357}
5358
5365{
5366 Q_D(QQuickItem);
5367 d->componentComplete = true;
5368 if (d->_stateGroup)
5369 d->_stateGroup->componentComplete();
5370 if (d->_anchors) {
5371 d->_anchors->componentComplete();
5372 QQuickAnchorsPrivate::get(d->_anchors)->updateOnComplete();
5373 }
5374
5375 if (d->extra.isAllocated()) {
5376#if QT_CONFIG(quick_shadereffect)
5377 if (d->extra->layer)
5378 d->extra->layer->componentComplete();
5379#endif
5380
5381 if (d->extra->keyHandler)
5382 d->extra->keyHandler->componentComplete();
5383
5384 if (d->extra->contents)
5385 d->extra->contents->complete();
5386 }
5387
5388 if (d->window && d->dirtyAttributes) {
5389 d->addToDirtyList();
5390 QQuickWindowPrivate::get(d->window)->dirtyItem(this);
5391 }
5392
5393#if QT_CONFIG(accessibility)
5394 if (d->isAccessible && d->effectiveVisible) {
5395 QAccessibleEvent ev(this, QAccessible::ObjectShow);
5396 QAccessible::updateAccessibility(&ev);
5397 }
5398#endif
5399}
5400
5402{
5403 Q_Q(QQuickItem);
5404 if (!_stateGroup) {
5406 if (!componentComplete)
5409 q, QQuickItem, SIGNAL(stateChanged(QString)));
5410 }
5411
5412 return _stateGroup;
5413}
5414
5416{
5417 switch (origin()) {
5418 default:
5420 return QPointF(0, 0);
5421 case QQuickItem::Top:
5422 return QPointF(width / 2., 0);
5424 return QPointF(width, 0);
5425 case QQuickItem::Left:
5426 return QPointF(0, height / 2.);
5427 case QQuickItem::Center:
5428 return QPointF(width / 2., height / 2.);
5429 case QQuickItem::Right:
5430 return QPointF(width, height / 2.);
5432 return QPointF(0, height);
5433 case QQuickItem::Bottom:
5434 return QPointF(width / 2., height);
5436 return QPointF(width, height);
5437 }
5438}
5439
5455{
5456 Q_Q(QQuickItem);
5457
5458 bool childWantsIt = false;
5460 // Inform the children in paint order: by the time we visit leaf items,
5461 // they can see any consequences in their parents
5462 const auto children = paintOrderChildItems();
5463 for (QQuickItem *child : children)
5464 childWantsIt |= QQuickItemPrivate::get(child)->transformChanged(transformedItem);
5465 }
5466
5467#if QT_CONFIG(quick_shadereffect)
5468 if (q == transformedItem) {
5469 if (extra.isAllocated() && extra->layer)
5470 extra->layer->updateMatrix();
5471 }
5472#endif
5473 const bool thisWantsIt = q->flags().testFlag(QQuickItem::ItemObservesViewport);
5474 const bool ret = childWantsIt || thisWantsIt;
5476 qCDebug(lcVP) << "turned off subtree transformChanged notification after checking all children of" << q;
5478 }
5479 // If ItemObservesViewport, clipRect() calculates the intersection with the viewport;
5480 // so each time the item moves in the viewport, its clipnode needs to be updated.
5481 if (thisWantsIt && q->clip() && !(dirtyAttributes & QQuickItemPrivate::Clip))
5483 return ret;
5484}
5485
5504 const QPointF &startPos,
5505 const QVector2D &activeTranslation,
5506 qreal startScale,
5507 qreal activeScale,
5508 qreal startRotation,
5509 qreal activeRotation)
5510{
5511 Q_Q(QQuickItem);
5512 QVector3D xformOrigin(q->transformOriginPoint());
5513 QMatrix4x4 startMatrix;
5514 startMatrix.translate(float(startPos.x()), float(startPos.y()));
5515 startMatrix.translate(xformOrigin);
5516 startMatrix.scale(float(startScale));
5517 startMatrix.rotate(float(startRotation), 0, 0, -1);
5518 startMatrix.translate(-xformOrigin);
5519
5520 const QVector3D centroidParentVector(centroidParentPos);
5521 QMatrix4x4 mat;
5522 mat.translate(centroidParentVector);
5523 mat.rotate(float(activeRotation), 0, 0, 1);
5524 mat.scale(float(activeScale));
5525 mat.translate(-centroidParentVector);
5526 mat.translate(QVector3D(activeTranslation));
5527
5528 mat = mat * startMatrix;
5529
5530 QPointF xformOriginPoint = q->transformOriginPoint();
5531 QPointF pos = mat.map(xformOriginPoint);
5532 pos -= xformOriginPoint;
5533
5534 return pos;
5535}
5536
5560{
5561 Q_Q(QQuickItem);
5563 QQuickItemPrivate *p = this;
5564 do {
5565 if (qmlobject_cast<QQuickRootItem *>(p->q_ptr)) {
5566 // found the root item without finding a different DA:
5567 // it means we don't need to repeat this search next time.
5568 // TODO maybe optimize further: make this function recursive, and
5569 // set it to false on each item that we visit in the tail
5571 break;
5572 }
5573 if (p->extra.isAllocated()) {
5574 if (auto da = p->extra->subsceneDeliveryAgent)
5575 return da;
5576 }
5577 p = p->parentItem ? QQuickItemPrivate::get(p->parentItem) : nullptr;
5578 } while (p);
5579 // arriving here is somewhat unexpected: a detached root can easily be created (just set an item's parent to null),
5580 // but why would we deliver events to that subtree? only if root got detached while an item in that subtree still has a grab?
5581 qCDebug(lcPtr) << "detached root of" << q << "is not a QQuickRootItem and also does not have its own DeliveryAgent";
5582 }
5583 if (window)
5584 return QQuickWindowPrivate::get(window)->deliveryAgent;
5585 return nullptr;
5586}
5587
5593
5603{
5604 Q_Q(QQuickItem);
5605 // We are (about to be) sure that it has one now; but just to save space,
5606 // we avoid storing a DA pointer in each item; so deliveryAgent() always needs to
5607 // go up the hierarchy to find it. maybeHasSubsceneDeliveryAgent tells it to do that.
5609 if (extra.isAllocated() && extra->subsceneDeliveryAgent)
5610 return extra->subsceneDeliveryAgent;
5611 extra.value().subsceneDeliveryAgent = new QQuickDeliveryAgent(q);
5612 qCDebug(lcPtr) << "created new" << extra->subsceneDeliveryAgent;
5613 // every subscene root needs to be a focus scope so that when QQuickItem::forceActiveFocus()
5614 // goes up the parent hierarchy, it finds the subscene root and calls setFocus() on it
5616 return extra->subsceneDeliveryAgent;
5617}
5618
5620{
5621 if (!extra.isAllocated() || !extra->keyHandler)
5622 return false;
5623
5624 if (post)
5625 e->accept();
5626
5627 if (e->type() == QEvent::KeyPress)
5628 extra->keyHandler->keyPressed(e, post);
5629 else
5630 extra->keyHandler->keyReleased(e, post);
5631
5632 return e->isAccepted();
5633}
5634
5636{
5637 Q_Q(QQuickItem);
5638 const auto eventType = event->type();
5639 const bool focusAccepted = setFocusIfNeeded(eventType);
5640
5641 switch (eventType) {
5643 q->mousePressEvent(static_cast<QMouseEvent *>(event));
5644 break;
5646 q->mouseReleaseEvent(static_cast<QMouseEvent *>(event));
5647 break;
5649 q->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event));
5650 break;
5651#if QT_CONFIG(wheelevent)
5652 case QEvent::Wheel:
5653 q->wheelEvent(static_cast<QWheelEvent*>(event));
5654 break;
5655#endif
5656 case QEvent::TouchBegin:
5658 case QEvent::TouchEnd:
5660 q->touchEvent(static_cast<QTouchEvent *>(event));
5661 break;
5662 default:
5663 break;
5664 }
5665
5666 if (focusAccepted)
5667 event->accept();
5668}
5669
5671{
5672 Q_Q(QQuickItem);
5673
5674 Q_ASSERT(e->isAccepted());
5675 if (filterKeyEvent(e, false))
5676 return;
5677 else
5678 e->accept();
5679
5680 if (e->type() == QEvent::KeyPress)
5681 q->keyPressEvent(e);
5682 else
5683 q->keyReleaseEvent(e);
5684
5685 if (e->isAccepted())
5686 return;
5687
5688 if (filterKeyEvent(e, true) || !q->window())
5689 return;
5690
5691 //only care about KeyPress now
5692 if (e->type() == QEvent::KeyPress &&
5693 (q == q->window()->contentItem() || q->activeFocusOnTab())) {
5694 bool res = false;
5695 if (!(e->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
5696 if (e->key() == Qt::Key_Backtab
5697 || (e->key() == Qt::Key_Tab && (e->modifiers() & Qt::ShiftModifier)))
5699 else if (e->key() == Qt::Key_Tab)
5701 if (res)
5702 e->setAccepted(true);
5703 }
5704 }
5705}
5706
5707#if QT_CONFIG(im)
5708void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
5709{
5710 Q_Q(QQuickItem);
5711
5712 Q_ASSERT(e->isAccepted());
5713 if (extra.isAllocated() && extra->keyHandler) {
5714 extra->keyHandler->inputMethodEvent(e, false);
5715
5716 if (e->isAccepted())
5717 return;
5718 else
5719 e->accept();
5720 }
5721
5722 q->inputMethodEvent(e);
5723
5724 if (e->isAccepted())
5725 return;
5726
5727 if (extra.isAllocated() && extra->keyHandler) {
5728 e->accept();
5729
5730 extra->keyHandler->inputMethodEvent(e, true);
5731 }
5732}
5733#endif // im
5734
5736{
5737 if (extra.isAllocated() && extra->keyHandler)
5738 extra->keyHandler->shortcutOverrideEvent(event);
5739 else
5740 event->ignore();
5741}
5742
5744{
5745 if (!hasPointerHandlers())
5746 return false;
5747 for (QQuickPointerHandler *handler : extra->pointerHandlers) {
5748 if (handler->wantsEventPoint(event, point))
5749 return true;
5750 }
5751 return false;
5752}
5753
5765{
5766 bool delivered = false;
5767 if (extra.isAllocated()) {
5768 for (QQuickPointerHandler *handler : extra->pointerHandlers) {
5769 bool avoidThisHandler = false;
5771 qmlobject_cast<const QQuickHoverHandler *>(handler)) {
5772 avoidThisHandler = true;
5773 } else if (avoidGrabbers) {
5774 for (auto &p : event->points()) {
5775 if (event->exclusiveGrabber(p) == handler || event->passiveGrabbers(p).contains(handler)) {
5776 avoidThisHandler = true;
5777 break;
5778 }
5779 }
5780 }
5781 if (!avoidThisHandler &&
5782 !QQuickPointerHandlerPrivate::deviceDeliveryTargets(event->device()).contains(handler)) {
5783 handler->handlePointerEvent(event);
5784 delivered = true;
5785 }
5786 }
5787 }
5788 return delivered;
5789}
5790
5805{
5806 if (change == ItemSceneChange)
5807 emit windowChanged(value.window);
5808}
5809
5810#if QT_CONFIG(im)
5815void QQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
5816{
5817 if (hasActiveFocus())
5818 QGuiApplication::inputMethod()->update(queries);
5819}
5820#endif // im
5821
5827{
5828 Q_D(const QQuickItem);
5829 return QRectF(0, 0, d->width, d->height);
5830}
5831
5854{
5855 Q_D(const QQuickItem);
5856 QRectF ret(0, 0, d->width, d->height);
5858 if (QQuickItem *viewport = viewportItem()) {
5859 // if the viewport is already "this", there's nothing to intersect;
5860 // and don't call clipRect() again, to avoid infinite recursion
5861 if (viewport == this)
5862 return ret;
5863 const auto mappedViewportRect = mapRectFromItem(viewport, viewport->clipRect());
5864 qCDebug(lcVP) << this << "intersecting" << viewport << mappedViewportRect << ret << "->" << mappedViewportRect.intersected(ret);
5865 return mappedViewportRect.intersected(ret);
5866 }
5867 }
5868 return ret;
5869}
5870
5883{
5885 QQuickItem *par = parentItem();
5886 while (par) {
5887 if (par->flags().testFlag(QQuickItem::ItemIsViewport))
5888 return par;
5889 par = par->parentItem();
5890 }
5891 }
5892 return (window() ? window()->contentItem() : nullptr);
5893}
5894
5926{
5927 Q_D(const QQuickItem);
5928 return d->origin();
5929}
5930
5932{
5933 Q_D(QQuickItem);
5934 if (origin == d->origin())
5935 return;
5936
5937 d->extra.value().origin = origin;
5939
5940 emit transformOriginChanged(d->origin());
5941}
5942
5951{
5952 Q_D(const QQuickItem);
5953 if (d->extra.isAllocated() && !d->extra->userTransformOriginPoint.isNull())
5954 return d->extra->userTransformOriginPoint;
5955 return d->computeTransformOrigin();
5956}
5957
5962{
5963 Q_D(QQuickItem);
5964 if (d->extra.value().userTransformOriginPoint == point)
5965 return;
5966
5967 d->extra->userTransformOriginPoint = point;
5969}
5970
6126{
6127 Q_D(const QQuickItem);
6128 return d->z();
6129}
6130
6132{
6133 Q_D(QQuickItem);
6134 if (d->z() == v)
6135 return;
6136
6137 d->extra.value().z = v;
6138
6140 if (d->parentItem) {
6141 QQuickItemPrivate::get(d->parentItem)->markSortedChildrenDirty(this);
6143 }
6144
6145 emit zChanged();
6146
6147#if QT_CONFIG(quick_shadereffect)
6148 if (d->extra.isAllocated() && d->extra->layer)
6149 d->extra->layer->updateZ();
6150#endif
6151}
6152
6206{
6207 Q_D(const QQuickItem);
6208 return d->rotation();
6209}
6210
6212{
6213 Q_D(QQuickItem);
6214 if (d->rotation() == r)
6215 return;
6216
6217 d->extra.value().rotation = r;
6218
6220
6221 d->itemChange(ItemRotationHasChanged, r);
6222
6224}
6225
6306{
6307 Q_D(const QQuickItem);
6308 return d->scale();
6309}
6310
6312{
6313 Q_D(QQuickItem);
6314 if (d->scale() == s)
6315 return;
6316
6317 d->extra.value().scale = s;
6318
6320
6322}
6323
6435{
6436 Q_D(const QQuickItem);
6437 return d->opacity();
6438}
6439
6441{
6442 Q_D(QQuickItem);
6443 qreal o = qBound<qreal>(0, newOpacity, 1);
6444 if (d->opacity() == o)
6445 return;
6446
6447 d->extra.value().opacity = o;
6448
6450
6451 d->itemChange(ItemOpacityHasChanged, o);
6452
6454}
6455
6521{
6522 Q_D(const QQuickItem);
6523 return d->effectiveVisible;
6524}
6525
6527{
6528 if (visible == explicitVisible)
6529 return;
6530
6531 explicitVisible = visible;
6532 if (!visible)
6534
6535 const bool childVisibilityChanged = setEffectiveVisibleRecur(calcEffectiveVisible());
6536 if (childVisibilityChanged && parentItem)
6537 emit parentItem->visibleChildrenChanged(); // signal the parent, not this!
6538}
6539
6541{
6542 Q_D(QQuickItem);
6543 d->setVisible(v);
6544}
6545
6588{
6589 Q_D(const QQuickItem);
6590 return d->effectiveEnable;
6591}
6592
6594{
6595 Q_D(QQuickItem);
6596 if (e == d->explicitEnable)
6597 return;
6598
6599 d->explicitEnable = e;
6600
6601 QQuickItem *scope = parentItem();
6602 while (scope && !scope->isFocusScope())
6603 scope = scope->parentItem();
6604
6605 d->setEffectiveEnableRecur(scope, d->calcEffectiveEnable());
6606}
6607
6609{
6610 // An item is visible if it is a child of a visible parent, and not explicitly hidden.
6611 return explicitVisible && parentItem && QQuickItemPrivate::get(parentItem)->effectiveVisible;
6612}
6613
6615{
6616 Q_Q(QQuickItem);
6617
6618 if (newEffectiveVisible && !explicitVisible) {
6619 // This item locally overrides visibility
6620 return false; // effective visibility didn't change
6621 }
6622
6623 if (newEffectiveVisible == effectiveVisible) {
6624 // No change necessary
6625 return false; // effective visibility didn't change
6626 }
6627
6628 effectiveVisible = newEffectiveVisible;
6629 dirty(Visible);
6630 if (parentItem)
6632 if (window)
6633 if (auto agent = deliveryAgentPrivate(); agent)
6634 agent->removeGrabber(q, true, true, true);
6635
6636 bool childVisibilityChanged = false;
6637 for (int ii = 0; ii < childItems.size(); ++ii)
6638 childVisibilityChanged |= QQuickItemPrivate::get(childItems.at(ii))->setEffectiveVisibleRecur(newEffectiveVisible);
6639
6641#if QT_CONFIG(accessibility)
6642 if (isAccessible) {
6643 QAccessibleEvent ev(q, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide);
6644 QAccessible::updateAccessibility(&ev);
6645 }
6646#endif
6647 if (!inDestructor) {
6648 emit q->visibleChanged();
6649 if (childVisibilityChanged)
6650 emit q->visibleChildrenChanged();
6651 }
6652
6653 return true; // effective visibility DID change
6654}
6655
6657{
6658 // XXX todo - Should the effective enable of an element with no parent just be the current
6659 // effective enable? This would prevent pointless re-processing in the case of an element
6660 // moving to/from a no-parent situation, but it is different from what graphics view does.
6661 return explicitEnable && (!parentItem || QQuickItemPrivate::get(parentItem)->effectiveEnable);
6662}
6663
6664void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffectiveEnable)
6665{
6666 Q_Q(QQuickItem);
6667
6668 if (newEffectiveEnable && !explicitEnable) {
6669 // This item locally overrides enable
6670 return;
6671 }
6672
6673 if (newEffectiveEnable == effectiveEnable) {
6674 // No change necessary
6675 return;
6676 }
6677
6678 effectiveEnable = newEffectiveEnable;
6679
6681 if (da) {
6682 da->removeGrabber(q, true, true, true);
6683 if (scope && !effectiveEnable && activeFocus) {
6684 da->clearFocusInScope(scope, q, Qt::OtherFocusReason,
6687 }
6688 }
6689
6690 for (int ii = 0; ii < childItems.size(); ++ii) {
6691 QQuickItemPrivate::get(childItems.at(ii))->setEffectiveEnableRecur(
6692 (flags & QQuickItem::ItemIsFocusScope) && scope ? q : scope, newEffectiveEnable);
6693 }
6694
6695 if (scope && effectiveEnable && focus && da) {
6696 da->setFocusInScope(scope, q, Qt::OtherFocusReason,
6699 }
6700
6702#if QT_CONFIG(accessibility)
6703 if (isAccessible) {
6704 QAccessible::State changedState;
6705 changedState.disabled = true;
6706 changedState.focusable = true;
6707 QAccessibleStateChangeEvent ev(q, changedState);
6708 QAccessible::updateAccessibility(&ev);
6709 }
6710#endif
6711 emit q->enabledChanged();
6712}
6713
6715{
6716 return extra.isAllocated() && extra.value().transparentForPositioner;
6717}
6718
6720{
6721 extra.value().transparentForPositioner = transparent;
6722}
6723
6724
6726{
6727#define DIRTY_TO_STRING(value) if (dirtyAttributes & value) { \
6728 if (!rv.isEmpty()) \
6729 rv.append(QLatin1Char('|')); \
6730 rv.append(QLatin1String(#value)); \
6731}
6732
6733// QString rv = QLatin1String("0x") + QString::number(dirtyAttributes, 16);
6734 QString rv;
6735
6739 DIRTY_TO_STRING(Position);
6740 DIRTY_TO_STRING(Size);
6754
6755 return rv;
6756}
6757
6759{
6760 Q_Q(QQuickItem);
6761 if (!(dirtyAttributes & type) || (window && !prevDirtyItem)) {
6763 if (window && componentComplete) {
6765 QQuickWindowPrivate::get(window)->dirtyItem(q);
6766 }
6767 }
6768 if (type & (TransformOrigin | Transform | BasicTransform | Position | Size | Clip))
6770}
6771
6773{
6774 Q_Q(QQuickItem);
6775
6777 if (!prevDirtyItem) {
6779
6781 nextDirtyItem = p->dirtyItemList;
6783 prevDirtyItem = &p->dirtyItemList;
6784 p->dirtyItemList = q;
6785 p->dirtyItem(q);
6786 }
6788}
6789
6801
6803{
6804 ++extra.value().effectRefCount;
6805 if (extra->effectRefCount == 1) {
6807 if (parentItem)
6809 }
6810 if (hide) {
6811 if (++extra->hideRefCount == 1)
6813 }
6815}
6816
6818{
6819 Q_Q(QQuickItem);
6820 if (!refs)
6821 return;
6822 extra.value().recursiveEffectRefCount += refs;
6823 for (int ii = 0; ii < childItems.size(); ++ii) {
6825 QQuickItemPrivate::get(child)->recursiveRefFromEffectItem(refs);
6826 }
6827 // Polish may rely on the effect ref count so trigger one, if item is not visible
6828 // (if visible, it will be triggered automatically).
6829 if (!effectiveVisible && refs > 0 && extra.value().recursiveEffectRefCount == 1) // it wasn't referenced, now it's referenced
6830 q->polish();
6831}
6832
6834{
6835 Q_ASSERT(extra->effectRefCount);
6836 --extra->effectRefCount;
6837 if (extra->effectRefCount == 0) {
6839 if (parentItem)
6841 }
6842 if (unhide) {
6843 if (--extra->hideRefCount == 0)
6845 }
6847}
6848
6850{
6851 if (cull == culled)
6852 return;
6853
6854 culled = cull;
6855 if ((cull && ++extra.value().hideRefCount == 1) || (!cull && --extra.value().hideRefCount == 0))
6857}
6858
6860{
6861 Q_Q(QQuickItem);
6862 switch (change) {
6864 q->itemChange(change, data);
6865 // The newly added child or any of its descendants may have
6866 // ItemObservesViewport set, in which case we need to both
6867 // inform the item that the transform has changed, and re-apply
6868 // subtreeTransformChangedEnabled to both this item and its
6869 // ancestors.
6870 if (QQuickItemPrivate::get(data.item)->transformChanged(q)) {
6872 qCDebug(lcVP) << "turned on transformChanged notification for subtree of" << q;
6874 }
6876 }
6878 break;
6879 }
6881 q->itemChange(change, data);
6883 break;
6884 }
6886 q->itemChange(change, data);
6887 break;
6889 q->itemChange(change, data);
6891 break;
6892 }
6894 q->itemChange(change, data);
6896 break;
6897 }
6899 q->itemChange(change, data);
6901 break;
6902 }
6904 q->itemChange(change, data);
6906 break;
6907 }
6909 q->itemChange(change, data);
6910 break;
6912 q->itemChange(change, data);
6914 break;
6915 }
6917 // fall through
6919 q->itemChange(change, data);
6920 break;
6921 }
6922}
6923
6948{
6949 Q_D(const QQuickItem);
6950 return d->smooth;
6951}
6952void QQuickItem::setSmooth(bool smooth)
6953{
6954 Q_D(QQuickItem);
6955 if (d->smooth == smooth)
6956 return;
6957
6958 d->smooth = smooth;
6960
6962}
6963
6988// TODO FOCUS: Deprecate
6990{
6991 Q_D(const QQuickItem);
6992 return d->activeFocusOnTab;
6993}
6994void QQuickItem::setActiveFocusOnTab(bool activeFocusOnTab)
6995{
6996 Q_D(QQuickItem);
6997 if (d->activeFocusOnTab == activeFocusOnTab)
6998 return;
6999
7000 if (window()) {
7001 if ((this == window()->activeFocusItem()) && this != window()->contentItem() && !activeFocusOnTab) {
7002 qWarning("QQuickItem: Cannot set activeFocusOnTab to false once item is the active focus item.");
7003 return;
7004 }
7005 }
7006
7007 d->activeFocusOnTab = activeFocusOnTab;
7008
7009 emit activeFocusOnTabChanged(activeFocusOnTab);
7010}
7011
7032{
7033 Q_D(const QQuickItem);
7034 return d->antialiasingValid ? d->antialiasing : d->implicitAntialiasing;
7035}
7036
7038{
7039 Q_D(QQuickItem);
7040
7041 if (!d->antialiasingValid) {
7042 d->antialiasingValid = true;
7043 d->antialiasing = d->implicitAntialiasing;
7044 }
7045
7046 if (aa == d->antialiasing)
7047 return;
7048
7049 d->antialiasing = aa;
7051
7052 d->itemChange(ItemAntialiasingHasChanged, bool(d->antialiasing));
7053
7055}
7056
7058{
7059 Q_D(QQuickItem);
7060 if (!d->antialiasingValid)
7061 return;
7062
7063 d->antialiasingValid = false;
7064
7065 if (d->implicitAntialiasing != d->antialiasing)
7067}
7068
7070{
7071 Q_Q(QQuickItem);
7072 bool prev = q->antialiasing();
7074 if (componentComplete && (q->antialiasing() != prev))
7075 emit q->antialiasingChanged(q->antialiasing());
7076}
7077
7083QQuickItem::Flags QQuickItem::flags() const
7084{
7085 Q_D(const QQuickItem);
7086 return (QQuickItem::Flags)d->flags;
7087}
7088
7098{
7099 Q_D(QQuickItem);
7100 if (enabled)
7101 setFlags((Flags)(d->flags | (quint32)flag));
7102 else
7103 setFlags((Flags)(d->flags & ~(quint32)flag));
7104
7105 // We don't return early if the flag did not change. That's useful in case
7106 // we need to intentionally trigger this parent-chain traversal again.
7107 if (enabled && flag == ItemObservesViewport)
7108 d->enableSubtreeChangeNotificationsForParentHierachy();
7109}
7110
7112{
7113 Q_Q(QQuickItem);
7114
7115 QQuickItem *par = q->parentItem();
7116 while (par) {
7117 auto parPriv = QQuickItemPrivate::get(par);
7118 if (!parPriv->subtreeTransformChangedEnabled)
7119 qCDebug(lcVP) << "turned on transformChanged notification for subtree of" << par;
7120 parPriv->subtreeTransformChangedEnabled = true;
7121 par = par->parentItem();
7122 }
7123}
7124
7131{
7132 Q_D(QQuickItem);
7133
7134 if (int(flags & ItemIsFocusScope) != int(d->flags & ItemIsFocusScope)) {
7135 if (flags & ItemIsFocusScope && !d->childItems.isEmpty() && d->window) {
7136 qWarning("QQuickItem: Cannot set FocusScope once item has children and is in a window.");
7137 flags &= ~ItemIsFocusScope;
7138 } else if (d->flags & ItemIsFocusScope) {
7139 qWarning("QQuickItem: Cannot unset FocusScope flag.");
7141 }
7142 }
7143
7144 if (int(flags & ItemClipsChildrenToShape) != int(d->flags & ItemClipsChildrenToShape))
7145 d->dirty(QQuickItemPrivate::Clip);
7146
7147 d->flags = flags;
7148}
7149
7176{
7177 Q_D(const QQuickItem);
7178 return d->x;
7179}
7180
7182{
7183 Q_D(const QQuickItem);
7184 return d->y;
7185}
7186
7191{
7192 Q_D(const QQuickItem);
7193 return QPointF(d->x, d->y);
7194}
7195
7197{
7198 Q_D(QQuickItem);
7199 /* There are two ways in which this function might be called:
7200 a) Either directly by the user, or
7201 b) when a binding has evaluated to a new value and it writes
7202 the value back
7203 In the first case, we want to remove an existing binding, in
7204 the second case, we don't want to remove the binding which
7205 just wrote the value.
7206 removeBindingUnlessInWrapper takes care of this.
7207 */
7208 d->x.removeBindingUnlessInWrapper();
7209 if (qt_is_nan(v))
7210 return;
7211
7212 const qreal oldx = d->x.valueBypassingBindings();
7213 if (oldx == v)
7214 return;
7215
7216 d->x.setValueBypassingBindings(v);
7217
7219
7220 const qreal y = d->y.valueBypassingBindings();
7221 const qreal w = d->width.valueBypassingBindings();
7222 const qreal h = d->height.valueBypassingBindings();
7223 geometryChange(QRectF(v, y, w, h), QRectF(oldx, y, w, h));
7224}
7225
7227{
7228 Q_D(QQuickItem);
7229 d->y.removeBindingUnlessInWrapper();
7230 if (qt_is_nan(v))
7231 return;
7232
7233 const qreal oldy = d->y.valueBypassingBindings();
7234 if (oldy == v)
7235 return;
7236
7237 d->y.setValueBypassingBindings(v);
7238
7240
7241 // we use v instead of d->y, as that avoid a method call
7242 // and we have v anyway in scope
7243 const qreal x = d->x.valueBypassingBindings();
7244 const qreal w = d->width.valueBypassingBindings();
7245 const qreal h = d->height.valueBypassingBindings();
7246 geometryChange(QRectF(x, v, w, h), QRectF(x, oldy, w, h));
7247}
7248
7253{
7254 Q_D(QQuickItem);
7255
7256 const qreal oldx = d->x.valueBypassingBindings();
7257 const qreal oldy = d->y.valueBypassingBindings();
7258
7259 if (QPointF(oldx, oldy) == pos)
7260 return;
7261
7262 /* This preserves the bindings, because that was what the code used to do
7263 The effect of this is that you can have
7264 Item {
7265 Rectangle {
7266 x: someValue; y: someValue
7267 DragHandler {}
7268 }
7269 }
7270 and you can move the rectangle around; once someValue changes, the position gets
7271 reset again (even when a drag is currently ongoing).
7272 Whether we want this is up to discussion.
7273 */
7274
7275 d->x.setValueBypassingBindings(pos.x()); //TODO: investigate whether to break binding here or not
7276 d->y.setValueBypassingBindings(pos.y());
7277
7279
7280 const qreal w = d->width.valueBypassingBindings();
7281 const qreal h = d->height.valueBypassingBindings();
7282 geometryChange(QRectF(pos.x(), pos.y(), w, h), QRectF(oldx, oldy, w, h));
7283}
7284
7285/* The bindable methods return an object which supports inspection (hasBinding) and
7286 modification (setBinding, removeBinding) of the properties bindable state.
7287*/
7288QBindable<qreal> QQuickItem::bindableX()
7289{
7290 return QBindable<qreal>(&d_func()->x);
7291}
7292
7293QBindable<qreal> QQuickItem::bindableY()
7294{
7295 return QBindable<qreal>(&d_func()->y);
7296}
7297
7304{
7305 Q_D(const QQuickItem);
7306 return d->width;
7307}
7308
7310{
7311 Q_D(QQuickItem);
7312 d->width.removeBindingUnlessInWrapper();
7313 if (qt_is_nan(w))
7314 return;
7315
7316 d->widthValidFlag = true;
7317 const qreal oldWidth = d->width.valueBypassingBindings();
7318 if (oldWidth == w)
7319 return;
7320
7321 d->width.setValueBypassingBindings(w);
7322
7323 d->dirty(QQuickItemPrivate::Size);
7324
7325 const qreal x = d->x.valueBypassingBindings();
7326 const qreal y = d->y.valueBypassingBindings();
7327 const qreal h = d->height.valueBypassingBindings();
7328 geometryChange(QRectF(x, y, w, h), QRectF(x, y, oldWidth, h));
7329}
7330
7332{
7333 Q_D(QQuickItem);
7334 d->width.takeBinding();
7335 d->widthValidFlag = false;
7337}
7338
7345
7354{
7355 Q_D(const QQuickItem);
7356 return d->getImplicitWidth();
7357}
7358
7360{
7361 return QBindable<qreal>(&d_func()->width);
7362}
7363
7447{
7448 Q_D(QQuickItem);
7449 bool changed = w != d->implicitWidth;
7450 d->implicitWidth = w;
7451 // this uses valueBypassingBindings simply to avoid repeated "am I in a binding" checks
7452 if (d->width.valueBypassingBindings() == w || widthValid()) {
7453 if (changed)
7454 d->implicitWidthChanged();
7455 if (d->width.valueBypassingBindings() == w || widthValid())
7456 return;
7457 changed = false;
7458 }
7459
7460 const qreal oldWidth = d->width.valueBypassingBindings();
7461 Q_ASSERT(!d->width.hasBinding() || QQmlPropertyBinding::isUndefined(d->width.binding()));
7462 // we need to keep the binding if its undefined (therefore we can't use operator=/setValue)
7463 d->width.setValueBypassingBindings(w);
7464
7465 d->dirty(QQuickItemPrivate::Size);
7466
7467 const qreal x = d->x.valueBypassingBindings();
7468 const qreal y = d->y.valueBypassingBindings();
7469 const qreal width = w;
7470 const qreal height = d->height.valueBypassingBindings();
7471 geometryChange(QRectF(x, y, width, height), QRectF(x, y, oldWidth, height));
7472
7473 if (changed)
7474 d->implicitWidthChanged();
7475}
7476
7481{
7482 Q_D(const QQuickItem);
7483 /* Logic: The width is valid if we assigned a value
7484 or a binding to it. Note that a binding evaluation to
7485 undefined (and thus calling resetWidth) is detached [1];
7486 hasBinding will thus return false for it, which is
7487 what we want here, as resetting width should mean that
7488 width is invalid (until the binding evaluates to a
7489 non-undefined value again).
7490
7491 [1]: A detached binding is a binding which is not set on a property.
7492 In the case of QQmlPropertyBinding and resettable properties, it
7493 still gets reevaluated when it was detached due to the binding
7494 returning undefined, and it gets re-attached, once the binding changes
7495 to a non-undefined value (unless another binding has beenset in the
7496 meantime).
7497 See QQmlPropertyBinding::isUndefined and handleUndefinedAssignment
7498 */
7499
7500 return d->widthValid();
7501}
7502
7509{
7510 Q_D(const QQuickItem);
7511 return d->height;
7512}
7513
7515{
7516 Q_D(QQuickItem);
7517 // Note that we call removeUnlessInWrapper before returning in the
7518 // NaN and equal value cases; that ensures that an explicit setHeight
7519 // always removes the binding
7520 d->height.removeBindingUnlessInWrapper();
7521 if (qt_is_nan(h))
7522 return;
7523
7524 d->heightValidFlag = true;
7525 const qreal oldHeight = d->height.valueBypassingBindings();
7526 if (oldHeight == h)
7527 return;
7528
7529 d->height.setValueBypassingBindings(h);
7530
7531 d->dirty(QQuickItemPrivate::Size);
7532
7533 const qreal x = d->x.valueBypassingBindings();
7534 const qreal y = d->y.valueBypassingBindings();
7535 const qreal w = d->width.valueBypassingBindings();
7536 geometryChange(QRectF(x, y, w, h), QRectF(x, y, w, oldHeight));
7537}
7538
7540{
7541 Q_D(QQuickItem);
7542 // using takeBinding, we remove any existing binding from the
7543 // property, but preserve the existing value (and avoid some overhead
7544 // compared to calling setHeight(height())
7545 d->height.takeBinding();
7546 d->heightValidFlag = false;
7548}
7549
7556
7561
7563{
7564 Q_D(const QQuickItem);
7565 return d->getImplicitHeight();
7566}
7567
7569{
7570 return QBindable<qreal>(&d_func()->height);
7571}
7572
7574{
7575 Q_D(QQuickItem);
7576 bool changed = h != d->implicitHeight;
7577 d->implicitHeight = h;
7578 if (d->height.valueBypassingBindings() == h || heightValid()) {
7579 if (changed)
7580 d->implicitHeightChanged();
7581 if (d->height.valueBypassingBindings() == h || heightValid())
7582 return;
7583 changed = false;
7584 }
7585
7586 const qreal oldHeight = d->height.valueBypassingBindings();
7587 Q_ASSERT(!d->height.hasBinding() || QQmlPropertyBinding::isUndefined(d->height.binding()));
7588 // we need to keep the binding if its undefined (therefore we can't use operator=/setValue)
7589 d->height.setValueBypassingBindings(h);
7590
7591 d->dirty(QQuickItemPrivate::Size);
7592
7593 const qreal x = d->x.valueBypassingBindings();
7594 const qreal y = d->y.valueBypassingBindings();
7595 const qreal width = d->width.valueBypassingBindings();
7596 const qreal height = d->height.valueBypassingBindings();
7598 QRectF(x, y, width, oldHeight));
7599
7600 if (changed)
7601 d->implicitHeightChanged();
7602}
7603
7608{
7609 Q_D(QQuickItem);
7610 bool wChanged = w != d->implicitWidth;
7611 bool hChanged = h != d->implicitHeight;
7612
7613 d->implicitWidth = w;
7614 d->implicitHeight = h;
7615
7616 bool wDone = false;
7617 bool hDone = false;
7618 qreal width = d->width.valueBypassingBindings();
7619 qreal height = d->height.valueBypassingBindings();
7620 if (width == w || widthValid()) {
7621 if (wChanged)
7622 d->implicitWidthChanged();
7623 wDone = width == w || widthValid();
7624 wChanged = false;
7625 }
7626 if (height == h || heightValid()) {
7627 if (hChanged)
7628 d->implicitHeightChanged();
7629 hDone = height == h || heightValid();
7630 hChanged = false;
7631 }
7632 if (wDone && hDone)
7633 return;
7634
7635 const qreal oldWidth = width;
7636 const qreal oldHeight = height;
7637 if (!wDone) {
7638 width = w;
7639 d->width.setValueBypassingBindings(w);
7640 }
7641 if (!hDone) {
7642 height = h;
7643 d->height.setValueBypassingBindings(h);
7644 }
7645
7646 d->dirty(QQuickItemPrivate::Size);
7647
7648 const qreal x = d->x.valueBypassingBindings();
7649 const qreal y = d->y.valueBypassingBindings();
7651 QRectF(x, y, oldWidth, oldHeight));
7652
7653 if (!wDone && wChanged)
7654 d->implicitWidthChanged();
7655 if (!hDone && hChanged)
7656 d->implicitHeightChanged();
7657}
7658
7663{
7664 Q_D(const QQuickItem);
7665 return d->heightValid();
7666}
7667
7677{
7678 Q_D(const QQuickItem);
7679 return QSizeF(d->width, d->height);
7680}
7681
7682
7694{
7695 Q_D(QQuickItem);
7696 d->heightValidFlag = true;
7697 d->widthValidFlag = true;
7698
7699 const qreal oldHeight = d->height.valueBypassingBindings();
7700 const qreal oldWidth = d->width.valueBypassingBindings();
7701
7702 if (oldWidth == size.width() && oldHeight == size.height())
7703 return;
7704
7705 d->height.setValueBypassingBindings(size.height());
7706 d->width.setValueBypassingBindings(size.width());
7707
7708 d->dirty(QQuickItemPrivate::Size);
7709
7710 const qreal x = d->x.valueBypassingBindings();
7711 const qreal y = d->y.valueBypassingBindings();
7712 geometryChange(QRectF(x, y, size.width(), size.height()), QRectF(x, y, oldWidth, oldHeight));
7713}
7714
7785{
7786 Q_D(const QQuickItem);
7787 return d->activeFocus;
7788}
7789
7879{
7880 Q_D(const QQuickItem);
7881 return d->focus;
7882}
7883
7888
7890{
7891 Q_D(QQuickItem);
7892 // Need to find our nearest focus scope
7893 QQuickItem *scope = parentItem();
7894 while (scope && !scope->isFocusScope() && scope->parentItem())
7895 scope = scope->parentItem();
7896
7897 if (d->focus == focus && (!focus || !scope || QQuickItemPrivate::get(scope)->subFocusItem == this))
7898 return;
7899
7900 bool notifyListeners = false;
7901 if (d->window || d->parentItem) {
7902 if (d->window) {
7903 auto da = d->deliveryAgentPrivate();
7904 Q_ASSERT(da);
7905 if (focus)
7906 da->setFocusInScope(scope, this, reason);
7907 else
7908 da->clearFocusInScope(scope, this, reason);
7909 } else {
7910 // do the focus changes from setFocusInScope/clearFocusInScope that are
7911 // unrelated to a window
7912 QVarLengthArray<QQuickItem *, 20> changed;
7913 QQuickItem *oldSubFocusItem = QQuickItemPrivate::get(scope)->subFocusItem;
7914 if (oldSubFocusItem) {
7915 QQuickItemPrivate::get(oldSubFocusItem)->updateSubFocusItem(scope, false);
7916 QQuickItemPrivate::get(oldSubFocusItem)->focus = false;
7917 changed << oldSubFocusItem;
7918 } else if (!scope->isFocusScope() && scope->hasFocus()) {
7919 QQuickItemPrivate::get(scope)->focus = false;
7920 changed << scope;
7921 }
7922 d->updateSubFocusItem(scope, focus);
7923
7924 d->focus = focus;
7925 changed << this;
7926 notifyListeners = true;
7928
7929 QQuickDeliveryAgentPrivate::notifyFocusChangesRecur(changed.data(), changed.size() - 1, reason);
7930 }
7931 } else {
7932 QVarLengthArray<QQuickItem *, 20> changed;
7933 QQuickItem *oldSubFocusItem = d->subFocusItem;
7934 if (!isFocusScope() && oldSubFocusItem) {
7935 QQuickItemPrivate::get(oldSubFocusItem)->updateSubFocusItem(this, false);
7936 QQuickItemPrivate::get(oldSubFocusItem)->focus = false;
7937 changed << oldSubFocusItem;
7938 }
7939
7940 d->focus = focus;
7941 changed << this;
7942 notifyListeners = true;
7944
7945 QQuickDeliveryAgentPrivate::notifyFocusChangesRecur(changed.data(), changed.size() - 1, reason);
7946 }
7947 if (notifyListeners)
7948 d->notifyChangeListeners(QQuickItemPrivate::Focus, &QQuickItemChangeListener::itemFocusChanged, this, reason);
7949}
7950
7955{
7956 return flags() & ItemIsFocusScope;
7957}
7958
7966{
7967 Q_D(const QQuickItem);
7968 if (!isFocusScope())
7969 return nullptr;
7970 else
7971 return d->subFocusItem;
7972}
7973
7996{
7997 Q_D(const QQuickItem);
7998 uint policy = d->focusPolicy;
7999 if (activeFocusOnTab())
8001 return static_cast<Qt::FocusPolicy>(policy);
8002}
8003
8010{
8011 Q_D(QQuickItem);
8012 if (d->focusPolicy == policy)
8013 return;
8014
8015 d->focusPolicy = policy;
8017 emit focusPolicyChanged(policy);
8018}
8019
8029{
8030 if (!child || child == this)
8031 return false;
8032 const QQuickItem *ancestor = child;
8033 while ((ancestor = ancestor->parentItem())) {
8034 if (ancestor == this)
8035 return true;
8036 }
8037 return false;
8038}
8039
8051Qt::MouseButtons QQuickItem::acceptedMouseButtons() const
8052{
8053 Q_D(const QQuickItem);
8054 return d->acceptedMouseButtons();
8055}
8056
8066void QQuickItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)
8067{
8068 Q_D(QQuickItem);
8069 d->extra.setTag(d->extra.tag().setFlag(QQuickItemPrivate::LeftMouseButtonAccepted, buttons & Qt::LeftButton));
8070
8071 buttons &= ~Qt::LeftButton;
8072 if (buttons || d->extra.isAllocated()) {
8073 d->extra.value().acceptedMouseButtonsWithoutHandlers = buttons;
8074 d->extra.value().acceptedMouseButtons = d->extra->pointerHandlers.isEmpty() ? buttons : Qt::AllButtons;
8075 }
8076}
8077
8090{
8091 Q_D(const QQuickItem);
8092 return d->filtersChildMouseEvents;
8093}
8094
8105{
8106 Q_D(QQuickItem);
8107 d->filtersChildMouseEvents = filter;
8108}
8109
8114{
8115 Q_D(const QQuickItem);
8116 if (!d->window)
8117 return false;
8118
8119 // QQuickWindow handles QEvent::Leave to reset the lastMousePosition
8120 // FIXME: Using QPointF() as the reset value means an item will not be
8121 // under the mouse if the mouse is at 0,0 of the window.
8122 if (const_cast<QQuickItemPrivate *>(d)->deliveryAgentPrivate()->lastMousePosition == QPointF())
8123 return false;
8124
8126 return contains(mapFromScene(d->window->mapFromGlobal(cursorPos)));
8127}
8128
8138{
8139 Q_D(const QQuickItem);
8140 return d->hoverEnabled;
8141}
8142
8150{
8151 Q_D(QQuickItem);
8152 d->hoverEnabled = enabled;
8153 d->setHasHoverInChild(enabled);
8154 // The DA needs to resolve which items and handlers should now be hovered or unhovered.
8155 // Marking this item dirty ensures that flushFrameSynchronousEvents() will be called from the render loop,
8156 // even if this change is not in response to a mouse event and no item has already marked itself dirty.
8158}
8159
8171{
8172 Q_D(const QQuickItem);
8173 return d->touchEnabled;
8174}
8175
8185{
8186 Q_D(QQuickItem);
8187 d->touchEnabled = enabled;
8188}
8189
8191{
8192#if QT_CONFIG(cursor)
8193 Q_Q(QQuickItem);
8194
8195 // if we're asked to turn it off (because of an unsetcursor call, or a node
8196 // removal) then we should make sure it's really ok to turn it off.
8197 if (!hc && subtreeCursorEnabled) {
8198 if (hasCursor)
8199 return; // nope! sorry, I have a cursor myself
8200 for (QQuickItem *otherChild : std::as_const(childItems)) {
8201 QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild);
8202 if (otherChildPrivate->subtreeCursorEnabled || otherChildPrivate->hasCursor)
8203 return; // nope! sorry, something else wants it kept on.
8204 }
8205 }
8206
8208 QQuickItem *parent = q->parentItem();
8209 if (parent) {
8211 parentPrivate->setHasCursorInChild(hc);
8212 }
8213#else
8214 Q_UNUSED(hc);
8215#endif
8216}
8217
8219{
8220 Q_Q(QQuickItem);
8221
8222 // if we're asked to turn it off (because of a setAcceptHoverEvents call, or a node
8223 // removal) then we should make sure it's really ok to turn it off.
8224 if (!hasHover && subtreeHoverEnabled) {
8225 if (hoverEnabled)
8226 return; // nope! sorry, I need hover myself
8228 return; // nope! sorry, this item has enabled HoverHandlers
8229
8230 for (QQuickItem *otherChild : std::as_const(childItems)) {
8231 QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild);
8232 if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled)
8233 return; // nope! sorry, something else wants it kept on.
8234 if (otherChildPrivate->hasEnabledHoverHandlers())
8235 return; // nope! sorry, we have pointer handlers which are interested.
8236 }
8237 }
8238
8239 qCDebug(lcHoverTrace) << q << subtreeHoverEnabled << "->" << hasHover;
8240 subtreeHoverEnabled = hasHover;
8241 QQuickItem *parent = q->parentItem();
8242 if (parent) {
8244 parentPrivate->setHasHoverInChild(hasHover);
8245 }
8246}
8247
8248#if QT_CONFIG(cursor)
8249
8264QCursor QQuickItem::cursor() const
8265{
8266 Q_D(const QQuickItem);
8267 return d->extra.isAllocated()
8268 ? d->extra->cursor
8269 : QCursor();
8270}
8271
8278void QQuickItem::setCursor(const QCursor &cursor)
8279{
8280 Q_D(QQuickItem);
8281
8282 Qt::CursorShape oldShape = d->extra.isAllocated() ? d->extra->cursor.shape() : Qt::ArrowCursor;
8283 qCDebug(lcHoverTrace) << oldShape << "->" << cursor.shape();
8284
8285 if (oldShape != cursor.shape() || oldShape >= Qt::LastCursor || cursor.shape() >= Qt::LastCursor) {
8286 d->extra.value().cursor = cursor;
8287 if (d->window) {
8288 QWindow *renderWindow = QQuickRenderControl::renderWindowFor(d->window);
8289 QWindow *window = renderWindow ? renderWindow : d->window; // this may not be a QQuickWindow
8290 if (QQuickWindowPrivate::get(d->window)->cursorItem == this)
8291 window->setCursor(cursor);
8292 }
8293 }
8294
8295 QPointF updateCursorPos;
8296 if (!d->hasCursor) {
8297 d->hasCursor = true;
8298 if (d->window) {
8299 QWindow *renderWindow = QQuickRenderControl::renderWindowFor(d->window);
8300 QWindow *window = renderWindow ? renderWindow : d->window;
8303 updateCursorPos = pos;
8304 }
8305 }
8306 d->setHasCursorInChild(d->hasCursor || d->hasCursorHandler);
8307 if (!updateCursorPos.isNull())
8308 QQuickWindowPrivate::get(d->window)->updateCursor(updateCursorPos);
8309}
8310
8317void QQuickItem::unsetCursor()
8318{
8319 Q_D(QQuickItem);
8320 qCDebug(lcHoverTrace) << "clearing cursor";
8321 if (!d->hasCursor)
8322 return;
8323 d->hasCursor = false;
8324 d->setHasCursorInChild(d->hasCursorHandler);
8325 if (d->extra.isAllocated())
8326 d->extra->cursor = QCursor();
8327
8328 if (d->window) {
8329 QQuickWindowPrivate *windowPrivate = QQuickWindowPrivate::get(d->window);
8330 if (windowPrivate->cursorItem == this) {
8331 QPointF pos = d->window->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition);
8332 windowPrivate->updateCursor(pos);
8333 }
8334 }
8335}
8336
8344QCursor QQuickItemPrivate::effectiveCursor(const QQuickPointerHandler *handler) const
8345{
8346 Q_Q(const QQuickItem);
8347 if (!handler)
8348 return q->cursor();
8349 bool hoverCursorSet = false;
8350 QCursor hoverCursor;
8351 bool activeCursorSet = false;
8352 QCursor activeCursor;
8353 if (const QQuickHoverHandler *hoverHandler = qobject_cast<const QQuickHoverHandler *>(handler)) {
8354 hoverCursorSet = hoverHandler->isCursorShapeExplicitlySet();
8355 hoverCursor = hoverHandler->cursorShape();
8356 } else if (handler->active()) {
8357 activeCursorSet = handler->isCursorShapeExplicitlySet();
8358 activeCursor = handler->cursorShape();
8359 }
8360 if (activeCursorSet)
8361 return activeCursor;
8362 if (hoverCursorSet)
8363 return hoverCursor;
8364 return q->cursor();
8365}
8366
8387QQuickPointerHandler *QQuickItemPrivate::effectiveCursorHandler() const
8388{
8389 if (!hasPointerHandlers())
8390 return nullptr;
8391 QQuickPointerHandler* activeHandler = nullptr;
8392 QQuickPointerHandler* mouseHandler = nullptr;
8393 QQuickPointerHandler* nonMouseHandler = nullptr;
8394 for (QQuickPointerHandler *h : extra->pointerHandlers) {
8395 if (!h->isCursorShapeExplicitlySet())
8396 continue;
8397 QQuickHoverHandler *hoverHandler = qmlobject_cast<QQuickHoverHandler *>(h);
8398 // Prioritize any HoverHandler that is reacting to a non-mouse device.
8399 // Otherwise, choose the first hovered handler that is found.
8400 // TODO maybe: there was an idea to add QPointerDevice* as argument to this function
8401 // and check the device type, but why? HoverHandler already does that.
8402 if (!activeHandler && hoverHandler && hoverHandler->isHovered()) {
8403 qCDebug(lcHoverTrace) << hoverHandler << hoverHandler->acceptedDevices() << "wants to set cursor" << hoverHandler->cursorShape();
8404 if (hoverHandler->acceptedDevices().testFlag(QPointingDevice::DeviceType::Mouse)) {
8405 // If there's a conflict, the last-added HoverHandler wins. Maybe the user is overriding a default...
8406 if (mouseHandler && mouseHandler->cursorShape() != hoverHandler->cursorShape()) {
8407 qCDebug(lcHoverTrace) << "mouse cursor conflict:" << mouseHandler << "wants" << mouseHandler->cursorShape()
8408 << "but" << hoverHandler << "wants" << hoverHandler->cursorShape();
8409 }
8410 mouseHandler = hoverHandler;
8411 } else {
8412 // If there's a conflict, the last-added HoverHandler wins.
8413 if (nonMouseHandler && nonMouseHandler->cursorShape() != hoverHandler->cursorShape()) {
8414 qCDebug(lcHoverTrace) << "non-mouse cursor conflict:" << nonMouseHandler << "wants" << nonMouseHandler->cursorShape()
8415 << "but" << hoverHandler << "wants" << hoverHandler->cursorShape();
8416 }
8417 nonMouseHandler = hoverHandler;
8418 }
8419 }
8420 if (!hoverHandler && h->active())
8421 activeHandler = h;
8422 }
8423 if (activeHandler) {
8424 qCDebug(lcHoverTrace) << "active handler choosing cursor" << activeHandler << activeHandler->cursorShape();
8425 return activeHandler;
8426 }
8427 // Mouse events are often synthetic; so if a HoverHandler for a non-mouse device wanted to set the cursor,
8428 // let it win, unless more than kCursorOverrideTimeout ms have passed
8429 // since the last time the non-mouse handler actually reacted to an event.
8430 // We could miss the fact that a tablet stylus has left proximity, because we don't deliver proximity events to windows.
8431 if (nonMouseHandler) {
8432 if (mouseHandler) {
8433 const bool beforeTimeout =
8434 QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime <
8435 QQuickPointerHandlerPrivate::get(nonMouseHandler)->lastEventTime + kCursorOverrideTimeout;
8436 QQuickPointerHandler *winner = (beforeTimeout ? nonMouseHandler : mouseHandler);
8437 qCDebug(lcHoverTrace) << "non-mouse handler reacted last time:" << QQuickPointerHandlerPrivate::get(nonMouseHandler)->lastEventTime
8438 << "and mouse handler reacted at time:" << QQuickPointerHandlerPrivate::get(mouseHandler)->lastEventTime
8439 << "choosing cursor according to" << winner << winner->cursorShape();
8440 return winner;
8441 }
8442 qCDebug(lcHoverTrace) << "non-mouse handler choosing cursor" << nonMouseHandler << nonMouseHandler->cursorShape();
8443 return nonMouseHandler;
8444 }
8445 if (mouseHandler)
8446 qCDebug(lcHoverTrace) << "mouse handler choosing cursor" << mouseHandler << mouseHandler->cursorShape();
8447 return mouseHandler;
8448}
8449
8450#endif
8451
8467{
8468 Q_D(QQuickItem);
8469 if (!d->window)
8470 return;
8471 auto da = d->deliveryAgentPrivate();
8472 Q_ASSERT(da);
8473 auto eventInDelivery = da->eventInDelivery();
8474 if (!eventInDelivery) {
8475 qWarning() << "cannot grab mouse: no event is currently being delivered";
8476 return;
8477 }
8478 auto epd = da->mousePointData();
8479 eventInDelivery->setExclusiveGrabber(epd->eventPoint, this);
8480}
8481
8494{
8495 Q_D(QQuickItem);
8496 if (!d->window)
8497 return;
8498 auto da = d->deliveryAgentPrivate();
8499 Q_ASSERT(da);
8500 auto eventInDelivery = da->eventInDelivery();
8501 if (!eventInDelivery) {
8502 // do it the expensive way
8503 da->removeGrabber(this);
8504 return;
8505 }
8506 const auto &eventPoint = da->mousePointData()->eventPoint;
8507 if (eventInDelivery->exclusiveGrabber(eventPoint) == this)
8508 eventInDelivery->setExclusiveGrabber(eventPoint, nullptr);
8509}
8510
8517{
8518 Q_D(const QQuickItem);
8519 return d->keepMouse;
8520}
8521
8539{
8540 Q_D(QQuickItem);
8541 d->keepMouse = keep;
8542}
8543
8553void QQuickItem::grabTouchPoints(const QList<int> &ids)
8554{
8555 Q_D(QQuickItem);
8556 auto event = d->deliveryAgentPrivate()->eventInDelivery();
8557 if (Q_UNLIKELY(!event)) {
8558 qWarning() << "cannot grab: no event is currently being delivered";
8559 return;
8560 }
8561 for (auto pt : event->points()) {
8562 if (ids.contains(pt.id()))
8563 event->setExclusiveGrabber(pt, this);
8564 }
8565}
8566
8572{
8573 Q_D(QQuickItem);
8574 if (!d->window)
8575 return;
8576 d->deliveryAgentPrivate()->removeGrabber(this, false, true);
8577}
8578
8586{
8587 Q_D(const QQuickItem);
8588 return d->keepTouch;
8589}
8590
8609{
8610 Q_D(QQuickItem);
8611 d->keepTouch = keep;
8612}
8613
8633bool QQuickItem::contains(const QPointF &point) const
8634{
8635 Q_D(const QQuickItem);
8636 if (d->extra.isAllocated() && d->extra->mask) {
8637 if (auto quickMask = qobject_cast<QQuickItem *>(d->extra->mask))
8638 return quickMask->contains(point - quickMask->position());
8639
8640 bool res = false;
8641 QMetaMethod maskContains = d->extra->mask->metaObject()->method(d->extra->maskContainsIndex);
8642 maskContains.invoke(d->extra->mask,
8644 Q_RETURN_ARG(bool, res),
8645 Q_ARG(QPointF, point));
8646 return res;
8647 }
8648
8649 qreal x = point.x();
8650 qreal y = point.y();
8651 return x >= 0 && y >= 0 && x < d->width && y < d->height;
8652}
8653
8718{
8719 Q_D(const QQuickItem);
8720 if (!d->extra.isAllocated())
8721 return nullptr;
8722 return d->extra->mask.data();
8723}
8724
8726{
8727 Q_D(QQuickItem);
8728 const bool extraDataExists = d->extra.isAllocated();
8729 // an Item can't mask itself (to prevent infinite loop in contains())
8730 if (mask == static_cast<QObject *>(this))
8731 return;
8732 // mask is null, and we had no mask
8733 if (!extraDataExists && !mask)
8734 return;
8735 // mask is non-null and the same
8736 if (extraDataExists && d->extra->mask == mask)
8737 return;
8738
8739 QQuickItem *quickMask = d->extra.isAllocated() ? qobject_cast<QQuickItem *>(d->extra->mask)
8740 : nullptr;
8741 if (quickMask) {
8742 QQuickItemPrivate *maskPrivate = QQuickItemPrivate::get(quickMask);
8743 maskPrivate->registerAsContainmentMask(this, false); // removed from use as my mask
8744 }
8745
8746 if (!extraDataExists)
8747 d->extra.value(); // ensure extra exists
8748 if (mask) {
8749 int methodIndex = mask->metaObject()->indexOfMethod(QByteArrayLiteral("contains(QPointF)"));
8750 if (methodIndex < 0) {
8751 qmlWarning(this) << QStringLiteral("QQuickItem: Object set as mask does not have an invokable contains method, ignoring it.");
8752 return;
8753 }
8754 d->extra->maskContainsIndex = methodIndex;
8755 }
8756 d->extra->mask = mask;
8757 quickMask = qobject_cast<QQuickItem *>(mask);
8758 if (quickMask) {
8759 QQuickItemPrivate *maskPrivate = QQuickItemPrivate::get(quickMask);
8760 maskPrivate->registerAsContainmentMask(this, true); // telling maskPrivate that "this" is using it as mask
8761 }
8762 emit containmentMaskChanged();
8763}
8764
8778{
8779 QPointF p = mapToScene(point);
8780 if (item) {
8781 const QQuickWindow *itemWindow = item->window();
8782 if (itemWindow != nullptr && itemWindow != window())
8783 p = itemWindow->mapFromGlobal(window()->mapToGlobal(p));
8784
8785 p = item->mapFromScene(p);
8786 }
8787 return p;
8788}
8789
8800{
8801 Q_D(const QQuickItem);
8802 return d->itemToWindowTransform().map(point);
8803}
8804
8822QPointF QQuickItem::mapToGlobal(const QPointF &point) const
8823{
8824 Q_D(const QQuickItem);
8825 return d->windowToGlobalTransform().map(mapToScene(point));
8826}
8827
8841{
8842 Q_D(const QQuickItem);
8843 QTransform t = d->itemToWindowTransform();
8844 if (item)
8845 t *= QQuickItemPrivate::get(item)->windowToItemTransform();
8846 return t.mapRect(rect);
8847}
8848
8859{
8860 Q_D(const QQuickItem);
8861 return d->itemToWindowTransform().mapRect(rect);
8862}
8863
8877{
8878 QPointF p = point;
8879 if (item) {
8880 p = item->mapToScene(point);
8881
8882 if (item->window() != window())
8883 p = window()->mapFromGlobal(item->window()->mapToGlobal(p));
8884 }
8885 return mapFromScene(p);
8886}
8887
8898{
8899 Q_D(const QQuickItem);
8900 return d->windowToItemTransform().map(point);
8901}
8902
8926QPointF QQuickItem::mapFromGlobal(const QPointF &point) const
8927{
8928 Q_D(const QQuickItem);
8929 QPointF scenePoint = d->globalToWindowTransform().map(point);
8931 if (auto sceneTransform = da->sceneTransform())
8932 scenePoint = sceneTransform->map(scenePoint);
8933 }
8934 return mapFromScene(scenePoint);
8935}
8936
8950{
8951 Q_D(const QQuickItem);
8952 QTransform t = item?QQuickItemPrivate::get(item)->itemToWindowTransform():QTransform();
8953 t *= d->windowToItemTransform();
8954 return t.mapRect(rect);
8955}
8956
8967{
8968 Q_D(const QQuickItem);
8969 return d->windowToItemTransform().mapRect(rect);
8970}
8971
9026{
9027 Q_D(QQuickItem);
9028
9029 switch (ev->type()) {
9030#if QT_CONFIG(im)
9033 Qt::InputMethodQueries queries = query->queries();
9034 for (uint i = 0; i < 32; ++i) {
9035 Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i));
9036 if (q) {
9037 QVariant v = inputMethodQuery(q);
9038 query->setValue(q, v);
9039 }
9040 }
9041 query->accept();
9042 break;
9043 }
9045 inputMethodEvent(static_cast<QInputMethodEvent *>(ev));
9046 break;
9047#endif // im
9048 case QEvent::TouchBegin:
9050 case QEvent::TouchEnd:
9055#if QT_CONFIG(wheelevent)
9056 case QEvent::Wheel:
9057#endif
9058 d->deliverPointerEvent(ev);
9059 break;
9061 if (isVisible()) {
9062 ev->accept();
9063 update();
9064 }
9065 break;
9066 case QEvent::HoverEnter:
9067 hoverEnterEvent(static_cast<QHoverEvent*>(ev));
9068 break;
9069 case QEvent::HoverLeave:
9070 hoverLeaveEvent(static_cast<QHoverEvent*>(ev));
9071 break;
9072 case QEvent::HoverMove:
9073 hoverMoveEvent(static_cast<QHoverEvent*>(ev));
9074 break;
9075 case QEvent::KeyPress:
9076 case QEvent::KeyRelease:
9077 d->deliverKeyEvent(static_cast<QKeyEvent*>(ev));
9078 break;
9080 d->deliverShortcutOverrideEvent(static_cast<QKeyEvent*>(ev));
9081 break;
9082 case QEvent::FocusIn:
9083 focusInEvent(static_cast<QFocusEvent*>(ev));
9084 break;
9085 case QEvent::FocusOut:
9086 focusOutEvent(static_cast<QFocusEvent*>(ev));
9087 break;
9088 case QEvent::MouseMove:
9089 mouseMoveEvent(static_cast<QMouseEvent*>(ev));
9090 break;
9091#if QT_CONFIG(quick_draganddrop)
9092 case QEvent::DragEnter:
9093 dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
9094 break;
9095 case QEvent::DragLeave:
9096 dragLeaveEvent(static_cast<QDragLeaveEvent*>(ev));
9097 break;
9098 case QEvent::DragMove:
9099 dragMoveEvent(static_cast<QDragMoveEvent*>(ev));
9100 break;
9101 case QEvent::Drop:
9102 dropEvent(static_cast<QDropEvent*>(ev));
9103 break;
9104#endif // quick_draganddrop
9105#if QT_CONFIG(gestures)
9107 ev->ignore();
9108 break;
9109#endif // gestures
9112 for (QQuickItem *item : std::as_const(d->childItems))
9114 break;
9117 if (d->providesPalette())
9118 d->setCurrentColorGroup();
9119 for (QQuickItem *item : std::as_const(d->childItems))
9121 break;
9123 for (QQuickItem *item : std::as_const(d->childItems))
9125 break;
9126 default:
9127 return QObject::event(ev);
9128 }
9129
9130 return true;
9131}
9132
9133#ifndef QT_NO_DEBUG_STREAM
9135#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
9136 const
9137#endif
9139{
9140 QDebugStateSaver saver(debug);
9141 debug.nospace();
9142 if (!item) {
9143 debug << "QQuickItem(nullptr)";
9144 return debug;
9145 }
9146
9147 const QRectF rect(item->position(), QSizeF(item->width(), item->height()));
9148
9149 debug << item->metaObject()->className() << '(' << static_cast<void *>(item);
9150
9151 // Deferred properties will cause recursion when calling nameForObject
9152 // before the component is completed, so guard against this situation.
9153 if (item->isComponentComplete()) {
9155 const auto objectId = context->nameForObject(item);
9156 if (!objectId.isEmpty())
9157 debug << ", id=" << objectId;
9158 }
9159 }
9160 if (!item->objectName().isEmpty())
9161 debug << ", name=" << item->objectName();
9162 debug << ", parent=" << static_cast<void *>(item->parentItem())
9163 << ", geometry=";
9165 if (const qreal z = item->z())
9166 debug << ", z=" << z;
9167 if (item->flags().testFlag(QQuickItem::ItemIsViewport))
9168 debug << " \U0001f5bc"; // frame with picture
9170 debug << " \u23ff"; // observer eye
9171 debug << ')';
9172 return debug;
9173}
9174#endif // QT_NO_DEBUG_STREAM
9175
9186{
9187#if QT_CONFIG(quick_shadereffect)
9188 Q_D(const QQuickItem);
9189 return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ?
9190 d->extra->layer->effectSource()->isTextureProvider() : false;
9191#else
9192 return false;
9193#endif
9194}
9195
9206{
9207#if QT_CONFIG(quick_shadereffect)
9208 Q_D(const QQuickItem);
9209 return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ?
9210 d->extra->layer->effectSource()->textureProvider() : nullptr;
9211#else
9212 return 0;
9213#endif
9214}
9215
9258#if QT_CONFIG(quick_shadereffect)
9263QQuickItemLayer *QQuickItemPrivate::layer() const
9264{
9265 if (!extra.isAllocated() || !extra->layer) {
9266 extra.value().layer = new QQuickItemLayer(const_cast<QQuickItem *>(q_func()));
9267 if (!componentComplete)
9268 extra->layer->classBegin();
9269 }
9270 return extra->layer;
9271}
9272#endif
9273
9292{
9293 Q_Q(QQuickItem);
9294 QList<QEventPoint> touchPoints;
9295 QEventPoint::States eventStates;
9296
9297 bool anyPressOrReleaseInside = false;
9298 bool anyGrabber = false;
9299 for (auto &p : event->points()) {
9300 if (p.isAccepted())
9301 continue;
9302
9303 // include points where item is the grabber, or if any of its handlers is the grabber while some parent is filtering
9304 auto pointGrabber = event->exclusiveGrabber(p);
9305 bool isGrabber = (pointGrabber == q);
9306 if (!isGrabber && pointGrabber && isFiltering) {
9307 auto handlerGrabber = qmlobject_cast<QQuickPointerHandler *>(pointGrabber);
9308 if (handlerGrabber && handlerGrabber->parentItem() == q)
9309 isGrabber = true;
9310 }
9311 if (isGrabber)
9312 anyGrabber = true;
9313
9314 // include points inside the bounds if no other item is the grabber or if the item is filtering
9315 const auto localPos = q->mapFromScene(p.scenePosition());
9316 bool isInside = q->contains(localPos);
9317 bool hasAnotherGrabber = pointGrabber && pointGrabber != q;
9318 // if there's no exclusive grabber, look for passive grabbers during filtering
9319 if (isFiltering && !pointGrabber) {
9320 const auto pg = event->passiveGrabbers(p);
9321 if (!pg.isEmpty()) {
9322 // It seems unlikely to have multiple passive grabbers of one eventpoint with different grandparents.
9323 // So hopefully if we start from one passive grabber and go up the parent chain from there,
9324 // we will find any filtering parent items that exist.
9325 auto handler = qmlobject_cast<QQuickPointerHandler *>(pg.constFirst());
9326 if (handler)
9327 pointGrabber = handler->parentItem();
9328 }
9329 }
9330
9331 // filtering: (childMouseEventFilter) include points that are grabbed by children of the target item
9332 bool grabberIsChild = false;
9333 auto parent = qobject_cast<QQuickItem*>(pointGrabber);
9334 while (isFiltering && parent) {
9335 if (parent == q) {
9336 grabberIsChild = true;
9337 break;
9338 }
9339 parent = parent->parentItem();
9340 }
9341
9342 bool filterRelevant = isFiltering && grabberIsChild;
9343 if (!(isGrabber || (isInside && (!hasAnotherGrabber || isFiltering)) || filterRelevant))
9344 continue;
9345 if ((p.state() == QEventPoint::State::Pressed || p.state() == QEventPoint::State::Released) && isInside)
9346 anyPressOrReleaseInside = true;
9347 QEventPoint pCopy(p);
9348 eventStates |= p.state();
9349 if (p.state() == QEventPoint::State::Released)
9351 QMutableEventPoint::setPosition(pCopy, localPos);
9352 touchPoints.append(std::move(pCopy));
9353 }
9354
9355 // Now touchPoints will have only points which are inside the item.
9356 // But if none of them were just pressed inside, and the item has no other reason to care, ignore them anyway.
9357 if (touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering)) {
9358 *localized = QMutableTouchEvent(QEvent::None);
9359 return;
9360 }
9361
9362 // if all points have the same state, set the event type accordingly
9363 QEvent::Type eventType = event->type();
9364 switch (eventStates) {
9366 eventType = QEvent::TouchBegin;
9367 break;
9369 eventType = QEvent::TouchEnd;
9370 break;
9371 default:
9372 eventType = QEvent::TouchUpdate;
9373 break;
9374 }
9375
9376 QMutableTouchEvent ret(eventType, event->pointingDevice(), event->modifiers(), touchPoints);
9377 ret.setTarget(q);
9378 ret.setTimestamp(event->timestamp());
9379 ret.accept();
9380 *localized = ret;
9381}
9382
9384{
9385 return extra.isAllocated() && !extra->pointerHandlers.isEmpty();
9386}
9387
9389{
9390 if (!hasPointerHandlers())
9391 return false;
9392 for (QQuickPointerHandler *h : extra->pointerHandlers)
9393 if (auto *hh = qmlobject_cast<QQuickHoverHandler *>(h); hh && hh->enabled())
9394 return true;
9395 return false;
9396}
9397
9399{
9400 Q_ASSERT(h);
9401 Q_Q(QQuickItem);
9402 // Accept all buttons, and leave filtering to pointerEvent() and/or user JS,
9403 // because there can be multiple handlers...
9404 extra.value().acceptedMouseButtons = Qt::AllButtons;
9405 auto &handlers = extra.value().pointerHandlers;
9406 if (!handlers.contains(h))
9407 handlers.prepend(h);
9408 auto &res = extra.value().resourcesList;
9409 if (!res.contains(h)) {
9410 res.append(h);
9413 });
9414 }
9415}
9416
9418{
9419 Q_ASSERT(h);
9420 Q_Q(QQuickItem);
9421 auto &handlers = extra.value().pointerHandlers;
9422 handlers.removeOne(h);
9423 auto &res = extra.value().resourcesList;
9424 res.removeOne(h);
9426 if (handlers.isEmpty())
9427 extra.value().acceptedMouseButtons = extra.value().acceptedMouseButtonsWithoutHandlers;
9428}
9429
9430#if QT_CONFIG(quick_shadereffect)
9431QQuickItemLayer::QQuickItemLayer(QQuickItem *item)
9432 : m_item(item)
9433 , m_enabled(false)
9434 , m_mipmap(false)
9435 , m_smooth(false)
9436 , m_live(true)
9437 , m_componentComplete(true)
9439 , m_format(QQuickShaderEffectSource::RGBA8)
9440 , m_name("source")
9441 , m_effectComponent(nullptr)
9442 , m_effect(nullptr)
9443 , m_effectSource(nullptr)
9444 , m_textureMirroring(QQuickShaderEffectSource::MirrorVertically)
9445 , m_samples(0)
9446{
9447}
9448
9449QQuickItemLayer::~QQuickItemLayer()
9450{
9451 delete m_effectSource;
9452 delete m_effect;
9453}
9454
9469void QQuickItemLayer::setEnabled(bool e)
9470{
9471 if (e == m_enabled)
9472 return;
9473 m_enabled = e;
9474 if (m_componentComplete) {
9475 if (m_enabled)
9476 activate();
9477 else
9478 deactivate();
9479 }
9480
9481 emit enabledChanged(e);
9482}
9483
9484void QQuickItemLayer::classBegin()
9485{
9486 Q_ASSERT(!m_effectSource);
9487 Q_ASSERT(!m_effect);
9488 m_componentComplete = false;
9489}
9490
9491void QQuickItemLayer::componentComplete()
9492{
9493 Q_ASSERT(!m_componentComplete);
9494 m_componentComplete = true;
9495 if (m_enabled)
9496 activate();
9497}
9498
9499void QQuickItemLayer::activate()
9500{
9501 Q_ASSERT(!m_effectSource);
9502 m_effectSource = new QQuickShaderEffectSource();
9503 QQuickItemPrivate::get(m_effectSource)->setTransparentForPositioner(true);
9504
9505 QQuickItem *parentItem = m_item->parentItem();
9506 if (parentItem) {
9507 m_effectSource->setParentItem(parentItem);
9508 m_effectSource->stackAfter(m_item);
9509 }
9510
9511 m_effectSource->setSourceItem(m_item);
9512 m_effectSource->setHideSource(true);
9513 m_effectSource->setSmooth(m_smooth);
9514 m_effectSource->setLive(m_live);
9515 m_effectSource->setTextureSize(m_size);
9516 m_effectSource->setSourceRect(m_sourceRect);
9517 m_effectSource->setMipmap(m_mipmap);
9518 m_effectSource->setWrapMode(m_wrapMode);
9519 m_effectSource->setFormat(m_format);
9520 m_effectSource->setTextureMirroring(m_textureMirroring);
9521 m_effectSource->setSamples(m_samples);
9522
9523 if (m_effectComponent)
9524 activateEffect();
9525
9526 m_effectSource->setVisible(m_item->isVisible() && !m_effect);
9527
9528 updateZ();
9529 updateGeometry();
9530 updateOpacity();
9531 updateMatrix();
9532
9535}
9536
9537void QQuickItemLayer::deactivate()
9538{
9539 Q_ASSERT(m_effectSource);
9540
9541 if (m_effectComponent)
9542 deactivateEffect();
9543
9544 delete m_effectSource;
9545 m_effectSource = nullptr;
9546
9549}
9550
9551void QQuickItemLayer::activateEffect()
9552{
9553 Q_ASSERT(m_effectSource);
9554 Q_ASSERT(m_effectComponent);
9555 Q_ASSERT(!m_effect);
9556
9557 QObject *created = m_effectComponent->beginCreate(m_effectComponent->creationContext());
9558 m_effect = qobject_cast<QQuickItem *>(created);
9559 if (!m_effect) {
9560 qWarning("Item: layer.effect is not a QML Item.");
9561 m_effectComponent->completeCreate();
9562 delete created;
9563 return;
9564 }
9565 QQuickItem *parentItem = m_item->parentItem();
9566 if (parentItem) {
9567 m_effect->setParentItem(parentItem);
9568 m_effect->stackAfter(m_effectSource);
9569 }
9570 m_effect->setVisible(m_item->isVisible());
9571 m_effect->setProperty(m_name, QVariant::fromValue<QObject *>(m_effectSource));
9572 QQuickItemPrivate::get(m_effect)->setTransparentForPositioner(true);
9573 m_effectComponent->completeCreate();
9574}
9575
9576void QQuickItemLayer::deactivateEffect()
9577{
9578 Q_ASSERT(m_effectSource);
9579 Q_ASSERT(m_effectComponent);
9580
9581 delete m_effect;
9582 m_effect = nullptr;
9583}
9584
9585
9597void QQuickItemLayer::setEffect(QQmlComponent *component)
9598{
9599 if (component == m_effectComponent)
9600 return;
9601
9602 bool updateNeeded = false;
9603 if (m_effectSource && m_effectComponent) {
9604 deactivateEffect();
9605 updateNeeded = true;
9606 }
9607
9608 m_effectComponent = component;
9609
9610 if (m_effectSource && m_effectComponent) {
9611 activateEffect();
9612 updateNeeded = true;
9613 }
9614
9615 if (updateNeeded) {
9616 updateZ();
9617 updateGeometry();
9618 updateOpacity();
9619 updateMatrix();
9620 m_effectSource->setVisible(m_item->isVisible() && !m_effect);
9621 }
9622
9623 emit effectChanged(component);
9624}
9625
9626
9638void QQuickItemLayer::setMipmap(bool mipmap)
9639{
9640 if (mipmap == m_mipmap)
9641 return;
9642 m_mipmap = mipmap;
9643
9644 if (m_effectSource)
9645 m_effectSource->setMipmap(m_mipmap);
9646
9647 emit mipmapChanged(mipmap);
9648}
9649
9650
9668void QQuickItemLayer::setFormat(QQuickShaderEffectSource::Format f)
9669{
9670 if (f == m_format)
9671 return;
9672 m_format = f;
9673
9674 if (m_effectSource)
9675 m_effectSource->setFormat(m_format);
9676
9677 emit formatChanged(m_format);
9678}
9679
9680
9692void QQuickItemLayer::setSourceRect(const QRectF &sourceRect)
9693{
9694 if (sourceRect == m_sourceRect)
9695 return;
9696 m_sourceRect = sourceRect;
9697
9698 if (m_effectSource)
9699 m_effectSource->setSourceRect(m_sourceRect);
9700
9701 emit sourceRectChanged(sourceRect);
9702}
9703
9716void QQuickItemLayer::setSmooth(bool s)
9717{
9718 if (m_smooth == s)
9719 return;
9720 m_smooth = s;
9721
9722 if (m_effectSource)
9723 m_effectSource->setSmooth(m_smooth);
9724
9725 emit smoothChanged(s);
9726}
9727
9740void QQuickItemLayer::setLive(bool live)
9741{
9742 if (m_live == live)
9743 return;
9744 m_live = live;
9745
9746 if (m_effectSource)
9747 m_effectSource->setLive(m_live);
9748
9749 emit liveChanged(live);
9750}
9751
9765void QQuickItemLayer::setSize(const QSize &size)
9766{
9767 if (size == m_size)
9768 return;
9769 m_size = size;
9770
9771 if (m_effectSource)
9772 m_effectSource->setTextureSize(size);
9773
9774 emit sizeChanged(size);
9775}
9776
9795void QQuickItemLayer::setWrapMode(QQuickShaderEffectSource::WrapMode mode)
9796{
9797 if (mode == m_wrapMode)
9798 return;
9799 m_wrapMode = mode;
9800
9801 if (m_effectSource)
9802 m_effectSource->setWrapMode(m_wrapMode);
9803
9804 emit wrapModeChanged(mode);
9805}
9806
9822void QQuickItemLayer::setTextureMirroring(QQuickShaderEffectSource::TextureMirroring mirroring)
9823{
9824 if (mirroring == m_textureMirroring)
9825 return;
9826 m_textureMirroring = mirroring;
9827
9828 if (m_effectSource)
9829 m_effectSource->setTextureMirroring(m_textureMirroring);
9830
9831 emit textureMirroringChanged(mirroring);
9832}
9833
9859void QQuickItemLayer::setSamples(int count)
9860{
9861 if (m_samples == count)
9862 return;
9863
9864 m_samples = count;
9865
9866 if (m_effectSource)
9867 m_effectSource->setSamples(m_samples);
9868
9869 emit samplesChanged(count);
9870}
9871
9883void QQuickItemLayer::setName(const QByteArray &name) {
9884 if (m_name == name)
9885 return;
9886 if (m_effect) {
9887 m_effect->setProperty(m_name, QVariant());
9888 m_effect->setProperty(name, QVariant::fromValue<QObject *>(m_effectSource));
9889 }
9890 m_name = name;
9891 emit nameChanged(name);
9892}
9893
9894void QQuickItemLayer::itemOpacityChanged(QQuickItem *item)
9895{
9896 Q_UNUSED(item);
9897 updateOpacity();
9898}
9899
9900void QQuickItemLayer::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
9901{
9902 updateGeometry();
9903}
9904
9905void QQuickItemLayer::itemParentChanged(QQuickItem *item, QQuickItem *parent)
9906{
9907 Q_UNUSED(item);
9908 Q_ASSERT(item == m_item);
9909 Q_ASSERT(parent != m_effectSource);
9910 Q_ASSERT(parent == nullptr || parent != m_effect);
9911
9912 m_effectSource->setParentItem(parent);
9913 if (parent)
9914 m_effectSource->stackAfter(m_item);
9915
9916 if (m_effect) {
9917 m_effect->setParentItem(parent);
9918 if (parent)
9919 m_effect->stackAfter(m_effectSource);
9920 }
9921}
9922
9923void QQuickItemLayer::itemSiblingOrderChanged(QQuickItem *)
9924{
9925 m_effectSource->stackAfter(m_item);
9926 if (m_effect)
9927 m_effect->stackAfter(m_effectSource);
9928}
9929
9930void QQuickItemLayer::itemVisibilityChanged(QQuickItem *)
9931{
9932 QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
9933 if (!l)
9934 return;
9935 l->setVisible(m_item->isVisible());
9936}
9937
9938void QQuickItemLayer::updateZ()
9939{
9940 if (!m_componentComplete || !m_enabled)
9941 return;
9942 QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
9943 if (!l)
9944 return;
9945 l->setZ(m_item->z());
9946}
9947
9948void QQuickItemLayer::updateOpacity()
9949{
9950 QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
9951 if (!l)
9952 return;
9953 l->setOpacity(m_item->opacity());
9954}
9955
9956void QQuickItemLayer::updateGeometry()
9957{
9958 QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
9959 if (!l)
9960 return;
9961 // Avoid calling QQuickImage::boundingRect() or other overrides
9962 // which may not be up-to-date at this time (QTBUG-104442, 104536)
9963 QRectF bounds = m_item->QQuickItem::boundingRect();
9964 l->setSize(bounds.size());
9965 l->setPosition(bounds.topLeft() + m_item->position());
9966}
9967
9968void QQuickItemLayer::updateMatrix()
9969{
9970 // Called directly from transformChanged(), so needs some extra
9971 // checks.
9972 if (!m_componentComplete || !m_enabled)
9973 return;
9974 QQuickItem *l = m_effect ? (QQuickItem *) m_effect : (QQuickItem *) m_effectSource;
9975 if (!l)
9976 return;
9978 l->setScale(m_item->scale());
9979 l->setRotation(m_item->rotation());
9980 ld->transforms = QQuickItemPrivate::get(m_item)->transforms;
9981 if (ld->origin() != QQuickItemPrivate::get(m_item)->origin())
9982 ld->extra.value().origin = QQuickItemPrivate::get(m_item)->origin();
9984}
9985#endif // quick_shadereffect
9986
9988: z(0), scale(1), rotation(0), opacity(1),
9989 contents(nullptr), screenAttached(nullptr), layoutDirectionAttached(nullptr),
9990 enterKeyAttached(nullptr),
9991 keyHandler(nullptr),
9992#if QT_CONFIG(quick_shadereffect)
9993 layer(nullptr),
9994#endif
9995 effectRefCount(0), hideRefCount(0),
9996 recursiveEffectRefCount(0),
9997 opacityNode(nullptr), clipNode(nullptr), rootNode(nullptr),
9998 origin(QQuickItem::Center),
9999 transparentForPositioner(false)
10000{
10001}
10002
10003
10004#if QT_CONFIG(accessibility)
10005QAccessible::Role QQuickItemPrivate::effectiveAccessibleRole() const
10006{
10007 Q_Q(const QQuickItem);
10008 auto *attached = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(q, false);
10009 auto role = QAccessible::NoRole;
10010 if (auto *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(attached))
10011 role = accessibleAttached->role();
10012 if (role == QAccessible::NoRole)
10013 role = accessibleRole();
10014 return role;
10015}
10016
10017QAccessible::Role QQuickItemPrivate::accessibleRole() const
10018{
10019 return QAccessible::NoRole;
10020}
10021#endif
10022
10023// helper code to let a visual parent mark its visual children for the garbage collector
10024
10025namespace QV4 {
10026namespace Heap {
10028 static void markObjects(QV4::Heap::Base *that, QV4::MarkStack *markStack);
10029};
10030}
10031}
10032
10036
10038
10040{
10041 QObjectWrapper *This = static_cast<QObjectWrapper *>(that);
10042 if (QQuickItem *item = static_cast<QQuickItem*>(This->object())) {
10043 for (QQuickItem *child : std::as_const(QQuickItemPrivate::get(item)->childItems))
10045 }
10046 QObjectWrapper::markObjects(that, markStack);
10047}
10048
10050{
10051 return (engine->memoryManager->allocate<QQuickItemWrapper>(q_func()))->asReturnedValue();
10052}
10053
10055{
10056 QDebugStateSaver stateSaver(debug);
10057 debug.nospace() << "ChangeListener listener=" << listener.listener << " types=" << listener.types;
10058 return debug;
10059}
10060
10063{ return mapFromItem(item, QPointF(x, y) ); }
10064
10067{ return mapRectFromItem(item, rect); }
10068
10071{ return mapFromItem(item, QRectF(x, y, width, height)); }
10072
10075{ return mapToItem(item, QPoint(x, y)); }
10076
10079{ return mapRectToItem(item, rect); }
10080
10083{ return mapToItem(item, QRectF(x, y, width, height)); }
10084
10086QPointF QQuickItem::mapToGlobal(qreal x, qreal y) const
10087{ return mapToGlobal(QPointF(x, y)); }
10088
10090QPointF QQuickItem::mapFromGlobal(qreal x, qreal y) const
10091{ return mapFromGlobal(QPointF(x, y)); }
10092
10095
10097
10098#include <moc_qquickitem.cpp>
10099
10100#include "moc_qquickitem_p.cpp"
\inmodule QtGui
\inmodule QtCore
Definition qbytearray.h:57
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
Qt::CursorShape shape() const
Returns the cursor shape identifier.
Definition qcursor.cpp:498
\inmodule QtCore
\inmodule QtCore
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
virtual void setAccepted(bool accepted)
Definition qcoreevent.h:307
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
@ ApplicationPaletteChange
Definition qcoreevent.h:93
@ ShortcutOverride
Definition qcoreevent.h:158
@ FocusOut
Definition qcoreevent.h:67
@ InputMethod
Definition qcoreevent.h:120
@ NativeGesture
Definition qcoreevent.h:246
@ DragEnter
Definition qcoreevent.h:101
@ LocaleChange
Definition qcoreevent.h:122
@ InputMethodQuery
Definition qcoreevent.h:261
@ KeyRelease
Definition qcoreevent.h:65
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ StyleAnimationUpdate
Definition qcoreevent.h:272
@ FocusIn
Definition qcoreevent.h:66
@ TouchCancel
Definition qcoreevent.h:264
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ HoverLeave
Definition qcoreevent.h:176
@ HoverEnter
Definition qcoreevent.h:175
@ WindowActivate
Definition qcoreevent.h:83
@ LanguageChange
Definition qcoreevent.h:123
@ DragLeave
Definition qcoreevent.h:103
@ HoverMove
Definition qcoreevent.h:177
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ WindowDeactivate
Definition qcoreevent.h:84
@ MouseButtonRelease
Definition qcoreevent.h:61
Type type() const
Returns the event type.
Definition qcoreevent.h:304
bool isAccepted() const
Definition qcoreevent.h:308
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition qcoreevent.h:310
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
QList< QGraphicsItem * > childItems() const
QGraphicsWidget * window() const
bool hasFocus() const
Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input f...
void setParentItem(QGraphicsItem *parent)
Sets this item's parent item to newParent.
QPointF mapToScene(const QPointF &point) const
Maps the point point, which is in this item's coordinate system, to the scene's coordinate system,...
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
GraphicsItemFlags flags() const
Returns this item's flags.
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item's scene's coordinate system, to this item's coordinate sy...
static struct QGuiApplicationPrivate::QLastCursorPosition lastCursorPosition
static QStyleHints * styleHints()
Returns the application's style hints.
static QInputMethod * inputMethod()
returns the input method.
\inmodule QtGui
Definition qevent.h:246
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
The QInputMethodQueryEvent class provides an event sent by the input context to input objects.
Definition qevent.h:679
Qt::InputMethodQueries queries() const
Returns the properties queried by the event.
Definition qevent.h:684
The QKeyEvent class describes a key event.
Definition qevent.h:424
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition qevent.cpp:1468
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
void setHorizontalPolicy(Policy d)
void setVerticalPolicy(Policy d)
qsizetype size() const noexcept
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
bool removeOne(const AT &t)
Definition qlist.h:598
iterator end()
Definition qlist.h:626
qsizetype length() const noexcept
Definition qlist.h:399
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
iterator begin()
Definition qlist.h:625
const T & constFirst() const noexcept
Definition qlist.h:647
void append(parameter_type t)
Definition qlist.h:458
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector.
\inmodule QtCore
Definition qmetaobject.h:19
\inmodule QtGui
Definition qevent.h:196
static Q_GUI_EXPORT void detach(QEventPoint &p)
uint isQuickItem
Definition qobject.h:84
QObject * parent
Definition qobject.h:73
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
const QObjectList & children() const
Returns a list of child objects.
Definition qobject.h:201
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1389
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4323
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition qobject.h:348
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
\inmodule QtCore\reentrant
Definition qpoint.h:25
A base class for pointer events.
Definition qevent.h:73
The QQmlComponent class encapsulates a QML component definition.
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
QObject * object
Definition qqmllist.h:81
RemoveLastFunction removeLast
Definition qqmllist.h:89
void clearItem(QQuickItem *)
static QQuickAnchorsPrivate * get(QQuickAnchors *o)
~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
static bool isMouseOrWheelEvent(const QPointerEvent *ev)
static void notifyFocusChangesRecur(QQuickItem **item, int remaining, Qt::FocusReason reason)
static QQuickDeliveryAgent * currentOrItemDeliveryAgent(const QQuickItem *item)
Qt::EnterKeyType type
QQuickEnterKeyAttached(QObject *parent=nullptr)
\qmltype EnterKey \instantiates QQuickEnterKeyAttached \inqmlmodule QtQuick
void setType(Qt::EnterKeyType type)
static QQuickEnterKeyAttached * qmlAttachedProperties(QObject *)
bool matches(QQuickGeometryChange other) const
virtual void itemParentChanged(QQuickItem *, QQuickItem *)
virtual void itemSiblingOrderChanged(QQuickItem *)
virtual void itemChildAdded(QQuickItem *, QQuickItem *)
virtual ~QQuickItemChangeListener()
virtual void itemRotationChanged(QQuickItem *)
virtual void itemEnabledChanged(QQuickItem *)
virtual void itemOpacityChanged(QQuickItem *)
virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
virtual void itemImplicitWidthChanged(QQuickItem *)
virtual void itemChildRemoved(QQuickItem *, QQuickItem *)
virtual QQuickAnchorsPrivate * anchorPrivate()
virtual void itemDestroyed(QQuickItem *)
virtual void itemVisibilityChanged(QQuickItem *)
virtual void itemImplicitHeightChanged(QQuickItem *)
virtual void itemFocusChanged(QQuickItem *, Qt::FocusReason)
virtual void keyReleased(QKeyEvent *event, bool post)
virtual void componentComplete()
QQuickItemKeyFilter(QQuickItem *=nullptr)
virtual void shortcutOverrideEvent(QKeyEvent *event)
virtual void keyPressed(QKeyEvent *event, bool post)
virtual ~QQuickItemKeyFilter()
bool calcEffectiveVisible() const
QQuickItem ** prevDirtyItem
void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types)
void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types)
QQuickAnchors * _anchors
QQuickAnchorLine verticalCenter() const
QTransform windowToItemTransform() const
Returns a transform that maps points from window space into item space.
static void data_clear(QQmlListProperty< QObject > *)
QQmlListProperty< QQuickTransition > transitions()
QLazilyAllocated< ExtraData, ExtraDataTags > extra
static void children_removeLast(QQmlListProperty< QQuickItem > *)
void notifyChangeListeners(QQuickItemPrivate::ChangeTypes changeTypes, Fn &&function, Args &&...args)
QList< QQuickItem * > paintOrderChildItems() const
static QQuickItem * visibleChildren_at(QQmlListProperty< QQuickItem > *prop, qsizetype index)
quint32 subtreeCursorEnabled
void init(QQuickItem *parent)
QQuickDeliveryAgent * deliveryAgent()
virtual bool handlePointerEvent(QPointerEvent *, bool avoidGrabbers=false)
quint32 maybeHasSubsceneDeliveryAgent
QLayoutPolicy szPolicy
virtual bool transformChanged(QQuickItem *transformedItem)
static QQuickItem * prevTabChildItem(const QQuickItem *item, int start)
quint32 effectiveLayoutMirror
void deliverPointerEvent(QEvent *)
~QQuickItemPrivate() override
QQuickAnchors * anchors() const
\qmlpropertygroup QtQuick::Item::anchors \qmlproperty AnchorLine QtQuick::Item::anchors....
bool setFocusIfNeeded(QEvent::Type)
QSGTransformNode * itemNodeInstance
bool hasPointerHandlers() const
static qsizetype children_count(QQmlListProperty< QQuickItem > *)
void setLayoutMirror(bool mirror)
quint32 subtreeHoverEnabled
QPointer< QQuickItem > subFocusItem
QString dirtyToString() const
void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types)
quint64 _q_createJSWrapper(QQmlV4ExecutionEnginePtr engine)
void removeChild(QQuickItem *)
static void children_clear(QQmlListProperty< QQuickItem > *)
static qsizetype transform_count(QQmlListProperty< QQuickTransform > *list)
QQmlListProperty< QObject > resources()
static qsizetype data_count(QQmlListProperty< QObject > *)
\qmlproperty list<QtObject> QtQuick::Item::data \qmldefault
Qt::FocusReason lastFocusChangeReason() const
void derefFromEffectItem(bool unhide)
static QQuickItem * children_at(QQmlListProperty< QQuickItem > *, qsizetype)
static qsizetype resources_count(QQmlListProperty< QObject > *)
QTransform itemToWindowTransform() const
Returns a transform that maps points from item space into window space.
static QQuickItem * nextPrevItemInTabFocusChain(QQuickItem *item, bool forward, bool wrap=true)
quint32 inheritMirrorFromItem
void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &)
void itemToParentTransform(QTransform *) const
Modifies t with this item's local transform relative to its parent.
virtual void implicitHeightChanged()
void setSizePolicy(const QLayoutPolicy::Policy &horizontalPolicy, const QLayoutPolicy::Policy &verticalPolicy)
static void data_removeLast(QQmlListProperty< QObject > *)
QList< QQuickItem * > * sortedChildItems
QQmlListProperty< QQuickItem > visibleChildren()
static QObject * resources_at(QQmlListProperty< QObject > *, qsizetype)
virtual void mirrorChange()
QQmlListProperty< QQuickState > states()
void updateOrAddItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
QQuickStateGroup * _stateGroup
QVector< QQuickItemPrivate::ChangeListener > changeListeners
QQuickItem * parentItem
void addChild(QQuickItem *)
bool calcEffectiveEnable() const
static QQuickTransform * transform_at(QQmlListProperty< QQuickTransform > *list, qsizetype)
void deliverKeyEvent(QKeyEvent *)
static void resources_removeLast(QQmlListProperty< QObject > *)
QQuickAnchorLine right() const
QQuickItem * nextDirtyItem
static QObject * data_at(QQmlListProperty< QObject > *, qsizetype)
QString state() const
void setTransparentForPositioner(bool trans)
void dirty(DirtyType)
bool filterKeyEvent(QKeyEvent *, bool post)
void setImplicitAntialiasing(bool antialiasing)
static QQuickItem * nextTabChildItem(const QQuickItem *item, int start)
QQuickAnchorLine bottom() const
static void children_append(QQmlListProperty< QQuickItem > *, QQuickItem *)
static qsizetype visibleChildren_count(QQmlListProperty< QQuickItem > *prop)
qreal rotation() const
void localizedTouchEvent(const QTouchEvent *event, bool isFiltering, QMutableTouchEvent *localized)
virtual void dumpItemTree(int indent) const
virtual void removePointerHandler(QQuickPointerHandler *h)
quint32 inheritMirrorFromParent
QLayoutPolicy sizePolicy() const
void recursiveRefFromEffectItem(int refs)
quint32 subtreeTransformChangedEnabled
static bool focusNextPrev(QQuickItem *item, bool forward)
QQuickItemPrivate::focusNextPrev focuses the next/prev item in the tab-focus-chain.
void setEffectiveEnableRecur(QQuickItem *scope, bool)
QTransform windowToGlobalTransform() const
Returns a transform that maps points from window space into global space.
void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
QList< QQuickTransform * > transforms
QQuickWindow * window
virtual qreal getImplicitWidth() const
static void resources_append(QQmlListProperty< QObject > *, QObject *)
static bool canAcceptTabFocus(QQuickItem *item)
void deliverShortcutOverrideEvent(QKeyEvent *)
void setHasCursorInChild(bool hasCursor)
QQuickItem::TransformOrigin origin() const
qreal scale() const
bool setEffectiveVisibleRecur(bool)
void refWindow(QQuickWindow *)
void setLastFocusChangeReason(Qt::FocusReason reason)
QQuickAnchorLine left() const
virtual void setVisible(bool visible)
QQuickAnchorLine top() const
quint32 componentComplete
void markSortedChildrenDirty(QQuickItem *child)
QQuickDeliveryAgentPrivate * deliveryAgentPrivate()
virtual void addPointerHandler(QQuickPointerHandler *h)
bool hasEnabledHoverHandlers() const
quint32 inheritedLayoutMirror
QQmlListProperty< QQuickItem > children()
void refFromEffectItem(bool hide)
QQuickDeliveryAgent * ensureSubsceneDeliveryAgent()
void enableSubtreeChangeNotificationsForParentHierachy()
QQuickAnchorLine horizontalCenter() const
void setState(const QString &)
QTransform globalToWindowTransform() const
Returns a transform that maps points from global space into window space.
void updateSubFocusItem(QQuickItem *scope, bool focus)
Clears all sub focus items from scope.
QPointF computeTransformOrigin() const
quint32 implicitAntialiasing
void _q_resourceObjectDeleted(QObject *)
QQuickStateGroup * _states()
virtual qreal getImplicitHeight() const
bool anyPointerHandlerWants(const QPointerEvent *event, const QEventPoint &point) const
QQmlListProperty< QObject > data()
static void data_append(QQmlListProperty< QObject > *, QObject *)
static void transform_clear(QQmlListProperty< QQuickTransform > *list)
virtual QSGTransformNode * createTransformNode()
static QQuickItemPrivate * get(QQuickItem *item)
void setHasHoverInChild(bool hasHover)
bool isTransparentForPositioner() const
static void transform_append(QQmlListProperty< QQuickTransform > *list, QQuickTransform *)
QPointF adjustedPosForTransform(const QPointF &centroid, const QPointF &startPos, const QVector2D &activeTranslatation, qreal startScale, qreal activeScale, qreal startRotation, qreal activeRotation)
static void resources_clear(QQmlListProperty< QObject > *)
virtual void implicitWidthChanged()
QList< QQuickItem * > childItems
void setImplicitLayoutMirror(bool mirror, bool inherit)
QQuickAnchorLine baseline() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QPointF mapToScene(const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within the scene's coor...
QBindable< qreal > bindableWidth()
bool event(QEvent *) override
\reimp
void parentChanged(QQuickItem *)
void resetHeight()
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive focus-out events for an item.
void setFiltersChildMouseEvents(bool filter)
Sets whether pointer events intended for this item's children should be filtered through this item.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
void zChanged()
void baselineOffsetChanged(qreal)
virtual QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *)
Called on the render thread when it is time to sync the state of the item with the scene graph.
virtual void hoverEnterEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
Flags flags() const
Returns the item flags for this item.
void setKeepTouchGrab(bool)
Sets whether the touch points grabbed by this item should remain exclusively with this item.
void classBegin() override
\reimp Derived classes should call the base class method before adding their own action to perform at...
void setTransformOriginPoint(const QPointF &)
QRectF mapRectToItem(const QQuickItem *item, const QRectF &rect) const
Maps the given rect in this item's coordinate system to the equivalent rectangular area within item's...
QList< QQuickItem * > childItems() const
Returns the children of this item.
Q_INVOKABLE QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in item's coordinate system to the equivalent point within this item's coordinat...
void setAntialiasing(bool)
void setOpacity(qreal)
void setFocus(bool)
void setSize(const QSizeF &size)
void rotationChanged()
bool acceptTouchEvents() const
Returns whether touch events are accepted by this item.
TransformOrigin
\variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::o...
Definition qquickitem.h:171
QQuickItem * viewportItem() const
If the \l ItemObservesViewport flag is set, returns the nearest parent with the \l ItemIsViewport fla...
void scaleChanged()
void setScale(qreal)
void setSmooth(bool)
void setRotation(qreal)
virtual void mouseDoubleClickEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse double-click events for an ite...
Qt::MouseButtons acceptedMouseButtons() const
Returns the mouse buttons accepted by this item.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
void smoothChanged(bool)
void resetWidth()
void antialiasingChanged(bool)
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
bool isFocusScope() const
Returns true if this item is a focus scope, and false otherwise.
qreal implicitWidth
Definition qquickitem.h:114
virtual void mouseUngrabEvent()
This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has oc...
virtual void keyPressEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key press events for an item.
Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within item's coordinat...
qreal x
\qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item...
Definition qquickitem.h:72
void setParentItem(QQuickItem *parent)
qreal z
\qmlproperty real QtQuick::Item::z
Definition qquickitem.h:74
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void setAcceptHoverEvents(bool enabled)
If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accept...
QBindable< qreal > bindableY()
void opacityChanged()
QPointF mapFromScene(const QPointF &point) const
Maps the given point in the scene's coordinate system to the equivalent point within this item's coor...
QString state() const
\qmlproperty string QtQuick::Item::state
virtual void hoverMoveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
void ungrabTouchPoints()
void setState(const QString &)
qreal y
Defines the item's y position relative to its parent.
Definition qquickitem.h:73
bool activeFocusOnTab() const
\qmlproperty bool QtQuick::Item::activeFocusOnTab
bool hasActiveFocus() const
void setAcceptTouchEvents(bool accept)
If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accept...
Qt::FocusPolicy focusPolicy
\qmlproperty enumeration QtQuick::Item::focusPolicy
Definition qquickitem.h:104
bool isVisible() const
qreal baselineOffset() const
\qmlproperty int QtQuick::Item::baselineOffset
Q_INVOKABLE QQuickItem * childAt(qreal x, qreal y) const
\qmlmethod QtQuick::Item::childAt(real x, real y)
TransformOrigin transformOrigin
\qmlproperty enumeration QtQuick::Item::transformOrigin This property holds the origin point around w...
Definition qquickitem.h:108
virtual QSGTextureProvider * textureProvider() const
Returns the texture provider for an item.
QRectF childrenRect()
\qmlpropertygroup QtQuick::Item::childrenRect \qmlproperty real QtQuick::Item::childrenRect....
void setHeight(qreal)
bool hasFocus() const
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
void setEnabled(bool)
QObject * containmentMask
\qmlproperty QObject* QtQuick::Item::containmentMask
Definition qquickitem.h:116
virtual QRectF boundingRect() const
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons accepted by this item to buttons.
void ungrabMouse()
QSizeF size() const
bool keepTouchGrab() const
Returns whether the touch points grabbed by this item should exclusively remain with this item.
void setFlags(Flags flags)
Enables the specified flags for this item.
QQuickWindow * window() const
Returns the window in which this item is rendered.
void setContainmentMask(QObject *mask)
virtual void mousePressEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
~QQuickItem() override
Destroys the QQuickItem.
void setBaselineOffset(qreal)
bool acceptHoverEvents() const
Returns whether hover events are accepted by this item.
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
QQuickItem * scopedFocusItem() const
If this item is a focus scope, this returns the item in its focus chain that currently has focus.
QQuickItem * parentItem() const
bool filtersChildMouseEvents() const
Returns whether pointer events intended for this item's children should be filtered through this item...
QRectF mapRectFromItem(const QQuickItem *item, const QRectF &rect) const
Maps the given rect in item's coordinate system to the equivalent rectangular area within this item's...
void stackAfter(const QQuickItem *)
Moves the specified sibling item to the index after this item within the list of children.
void setVisible(bool)
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
void clipChanged(bool)
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
QQuickItem * parent
\qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.
Definition qquickitem.h:67
QTransform itemTransform(QQuickItem *, bool *) const
\qmlmethod point QtQuick::Item::mapFromItem(Item item, real x, real y) \qmlmethod point QtQuick::Item...
virtual void touchUngrabEvent()
This event handler can be reimplemented in a subclass to be notified when a touch ungrab event has oc...
void grabTouchPoints(const QList< int > &ids)
qreal implicitHeight
Definition qquickitem.h:115
bool clip() const
\qmlproperty bool QtQuick::Item::clip This property holds whether clipping is enabled.
QBindable< qreal > bindableHeight()
void setImplicitHeight(qreal)
bool keepMouseGrab() const
Returns whether mouse input should exclusively remain with this item.
QPointF position() const
bool isEnabled() const
bool heightValid() const
Returns whether the height property has been set explicitly.
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
Q_INVOKABLE void forceActiveFocus()
\qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::...
bool antialiasing
\qmlproperty bool QtQuick::Item::antialiasing
Definition qquickitem.h:113
bool smooth
\qmlproperty bool QtQuick::Item::smooth
Definition qquickitem.h:112
qreal rotation
\qmlproperty real QtQuick::Item::rotation This property holds the rotation of the item in degrees clo...
Definition qquickitem.h:106
void grabMouse()
bool widthValid() const
Returns whether the width property has been set explicitly.
virtual void touchEvent(QTouchEvent *event)
This event handler can be reimplemented in a subclass to receive touch events for an item.
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
virtual bool childMouseEventFilter(QQuickItem *, QEvent *)
Reimplement this method to filter the pointer events that are received by this item's children.
virtual void updatePolish()
This function should perform any layout as required for this item.
void setPosition(const QPointF &)
void setZ(qreal)
virtual void releaseResources()
This function is called when an item should release graphics resources which are not already managed ...
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key release events for an item.
void setWidth(qreal)
QQuickItem(QQuickItem *parent=nullptr)
Constructs a QQuickItem with the given parent.
QRectF mapRectToScene(const QRectF &rect) const
Maps the given rect in this item's coordinate system to the equivalent rectangular area within the sc...
virtual QRectF clipRect() const
Returns the rectangular area within this item that is currently visible in \l viewportItem(),...
qreal scale
\qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.
Definition qquickitem.h:107
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
@ ItemVisibleHasChanged
Definition qquickitem.h:148
@ ItemActiveFocusHasChanged
Definition qquickitem.h:151
@ ItemAntialiasingHasChanged
Definition qquickitem.h:153
@ ItemEnabledHasChanged
Definition qquickitem.h:155
@ ItemRotationHasChanged
Definition qquickitem.h:152
@ ItemOpacityHasChanged
Definition qquickitem.h:150
@ ItemParentHasChanged
Definition qquickitem.h:149
@ ItemChildAddedChange
Definition qquickitem.h:145
@ ItemChildRemovedChange
Definition qquickitem.h:146
@ ItemDevicePixelRatioHasChanged
Definition qquickitem.h:154
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive focus-in events for an item.
void setTransformOrigin(TransformOrigin)
void visibleChildrenChanged()
qreal opacity
\qmlproperty real QtQuick::Item::opacity
Definition qquickitem.h:78
void setFocusPolicy(Qt::FocusPolicy policy)
Sets the focus policy of this item to policy.
bool isUnderMouse() const
void setX(qreal)
QRectF mapRectFromScene(const QRectF &rect) const
Maps the given rect in the scene's coordinate system to the equivalent rectangular area within this i...
Flag
\qmltype Item \instantiates QQuickItem \inherits QtObject \inqmlmodule QtQuick
Definition qquickitem.h:129
@ ItemObservesViewport
Definition qquickitem.h:138
@ ItemClipsChildrenToShape
Definition qquickitem.h:130
bool enabled
\qmlproperty bool QtQuick::Item::enabled
Definition qquickitem.h:79
bool isAncestorOf(const QQuickItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child's parent,...
QBindable< qreal > bindableX()
void transformOriginChanged(TransformOrigin)
void resetAntialiasing()
void setClip(bool)
void focusChanged(bool)
void setImplicitWidth(qreal)
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
void setY(qreal)
void update()
Schedules a call to updatePaintNode() for this item.
void stackBefore(const QQuickItem *)
Moves the specified sibling item to the index before this item within the list of children.
QQmlListProperty< QQuickTransform > transform
\qmlproperty list<Transform> QtQuick::Item::transform This property holds the list of transformations...
Definition qquickitem.h:110
void polish()
Schedules a polish event for this item.
virtual bool isTextureProvider() const
Returns true if this item is a texture provider.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void setActiveFocusOnTab(bool)
void setImplicitSize(qreal, qreal)
QPointF transformOriginPoint
Definition qquickitem.h:109
void reset(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
void setUp(QQuickItem *)
void setLeft(QQuickItem *)
static QQuickKeyNavigationAttached * qmlAttachedProperties(QObject *)
void setTab(QQuickItem *)
QQuickKeyNavigationAttached(QObject *=nullptr)
\qmltype KeyNavigation \instantiates QQuickKeyNavigationAttached \inqmlmodule QtQuick
void setBacktab(QQuickItem *)
void keyReleased(QKeyEvent *event, bool post) override
void keyPressed(QKeyEvent *event, bool post) override
void setRight(QQuickItem *)
void setDown(QQuickItem *)
~QQuickKeysAttached() override
void keyPressed(QKeyEvent *event, bool post) override
static QQuickKeysAttached * qmlAttachedProperties(QObject *)
void keyReleased(QKeyEvent *event, bool post) override
QQuickKeysAttached(QObject *parent=nullptr)
\qmltype Keys \instantiates QQuickKeysAttached \inqmlmodule QtQuick
void released(QQuickKeyEvent *event)
void setPriority(Priority)
void pressed(QQuickKeyEvent *event)
void shortcutOverride(QQuickKeyEvent *event)
void shortcutOverrideEvent(QKeyEvent *event) override
void componentComplete() override
static QQuickLayoutMirroringAttached * qmlAttachedProperties(QObject *)
QQuickLayoutMirroringAttached(QObject *parent=nullptr)
\qmltype LayoutMirroring \instantiates QQuickLayoutMirroringAttached \inqmlmodule QtQuick
QInputDevice::DeviceTypes acceptedDevices
static QQuickPointerHandlerPrivate * get(QQuickPointerHandler *q)
static QVector< QObject * > & deviceDeliveryTargets(const QInputDevice *device)
QQuickItem * parentItem() const
\qmlproperty Item QtQuick::PointerHandler::parent
static QWindow * renderWindowFor(QQuickWindow *win, QPoint *offset=nullptr)
Returns the real window that win is being rendered to, if any.
QQmlListProperty< QQuickTransition > transitionsProperty()
\qmlproperty list<Transition> QtQuick::StateGroup::transitions This property holds a list of transiti...
void setState(const QString &)
QQmlListProperty< QQuickState > statesProperty()
\qmlproperty list<State> QtQuick::StateGroup::states This property holds a list of states defined by ...
void classBegin() override
Invoked after class creation, but before any properties have been set.
static QQuickTransformPrivate * get(QQuickTransform *transform)
QQuickTransformPrivate()
\qmltype Transform \instantiates QQuickTransform \inqmlmodule QtQuick
QList< QQuickItem * > items
void prependToItem(QQuickItem *)
QQuickTransform(QObject *parent=nullptr)
virtual void applyTo(QMatrix4x4 *matrix) const =0
void appendToItem(QQuickItem *)
~QQuickTransform() override
static QQuickWindowPrivate * get(QQuickWindow *c)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:672
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:732
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:729
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:669
constexpr void setY(qreal pos) noexcept
Sets the top edge of the rectangle to the given finite y coordinate.
Definition qrect.h:509
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
Definition qrect.h:818
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:511
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:735
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
Definition qrect.h:821
QRectF intersected(const QRectF &other) const noexcept
Definition qrect.h:847
constexpr void setX(qreal pos) noexcept
Sets the left edge of the rectangle to the given finite x coordinate.
Definition qrect.h:508
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
The QSGTextureProvider class encapsulates texture based entities in QML.
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis.
QTransform inverted(bool *invertible=nullptr) const
Returns an inverted copy of this matrix.
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
\inmodule QtGui
Definition qwindow.h:63
[Window class with invokable method]
Definition window.h:11
bool focus
[0]
QCursor cursor
rect
[4]
else opt state
[0]
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
static void formatQRect(QDebug &debug, const Rect &rect)
Definition qdebug_p.h:45
Definition qcompare.h:63
InputMethodQuery
@ ImMaximumTextLength
@ ImAnchorRectangle
@ ImSurroundingText
@ ImInputItemClipRectangle
@ ImCursorPosition
@ ImEnterKeyType
@ ImCurrentSelection
@ ImReadOnly
@ ImPreferredLanguage
@ ImFont
@ ImAnchorPosition
@ ImCursorRectangle
@ ImHints
@ ImEnabled
@ TabFocusAllControls
Definition qnamespace.h:118
@ LeftButton
Definition qnamespace.h:58
@ AllButtons
Definition qnamespace.h:90
FocusPolicy
Definition qnamespace.h:106
@ WheelFocus
Definition qnamespace.h:111
@ ClickFocus
Definition qnamespace.h:109
@ TabFocus
Definition qnamespace.h:108
CursorShape
@ LastCursor
@ ArrowCursor
@ Key_Escape
Definition qnamespace.h:663
@ Key_Yes
@ Key_Tab
Definition qnamespace.h:664
@ Key_Select
@ Key_Return
Definition qnamespace.h:667
@ Key_9
Definition qnamespace.h:539
@ Key_Context2
@ Key_Context1
@ Key_Right
Definition qnamespace.h:679
@ Key_Enter
Definition qnamespace.h:668
@ Key_Cancel
@ Key_Space
Definition qnamespace.h:513
@ Key_Hangup
@ Key_Context3
@ Key_VolumeUp
Definition qnamespace.h:852
@ Key_Backtab
Definition qnamespace.h:665
@ Key_VolumeDown
Definition qnamespace.h:850
@ Key_Left
Definition qnamespace.h:677
@ Key_NumberSign
Definition qnamespace.h:517
@ Key_0
Definition qnamespace.h:530
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
@ Key_Delete
Definition qnamespace.h:670
@ Key_Menu
Definition qnamespace.h:727
@ Key_Back
Definition qnamespace.h:846
@ Key_Context4
@ Key_Call
@ Key_Asterisk
Definition qnamespace.h:524
@ Key_No
@ Key_Flip
@ ShiftModifier
@ ControlModifier
@ AltModifier
@ DirectConnection
EnterKeyType
FocusReason
@ BacktabFocusReason
@ MouseFocusReason
@ OtherFocusReason
@ TabFocusReason
static void * context
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
#define Q_UNLIKELY(x)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT layer
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
Flags
#define qDebug
[1]
Definition qlogging.h:164
@ QtDebugMsg
Definition qlogging.h:30
#define qWarning
Definition qlogging.h:166
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
return ret
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
static Q_DECL_CONST_FUNCTION bool qt_is_nan(double d)
Definition qnumeric_p.h:112
#define SLOT(a)
Definition qobjectdefs.h:52
#define Q_RETURN_ARG(Type, data)
Definition qobjectdefs.h:64
#define Q_ARG(Type, data)
Definition qobjectdefs.h:63
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum mode
const GLfloat * m
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLboolean r
[2]
GLenum GLenum GLsizei const GLuint * ids
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
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLuint start
GLenum GLuint GLintptr offset
GLuint name
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLuint GLenum GLenum transform
GLhandleARB obj
[2]
GLdouble s
[6]
Definition qopenglext.h:235
GLenum query
GLuint res
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
GLfixed GLfixed GLint GLint order
GLenum GLenum GLenum GLenum GLenum scale
static qreal component(const QPointF &point, unsigned int i)
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:75
#define qmlobject_disconnect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Disconnect Signal of Sender from Method of Receiver.
#define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Connect Signal of Sender to Method of Receiver.
T qmlobject_cast(QObject *object)
This method is identical to qobject_cast<T>() except that it does not require lazy QMetaObjects to be...
QQuickItem * qmlobject_cast< QQuickItem * >(QObject *object)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define PRINT_LISTENERS()
QDebug operator<<(QDebug debug, const QQuickItem *item)
static bool itemZOrder_sort(QQuickItem *lhs, QQuickItem *rhs)
#define DIRTY_TO_STRING(value)
void debugFocusTree(QQuickItem *item, QQuickItem *scope=nullptr, int depth=1)
const SigMap sigMap[]
static void setActiveFocus(QQuickItem *item, Qt::FocusReason reason)
static QT_BEGIN_NAMESPACE const quint64 kCursorOverrideTimeout
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
Definition qquickitem.h:492
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
#define QStringLiteral(str)
#define QT_CONFIG(feature)
#define tr(X)
#define emit
#define Q_UNUSED(x)
#define QT_VERSION_CHECK(major, minor, patch)
#define QT_VERSION
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 DEFINE_OBJECT_VTABLE(classname)
#define V4_OBJECT2(DataClass, superClass)
Q_GUI_EXPORT QWindowPrivate * qt_window_private(QWindow *window)
Definition qwindow.cpp:2950
bool testFlag(MaskType mask, FlagType flag)
const char property[13]
Definition qwizard.cpp:101
if(qFloatDistance(a, b)<(1<< 7))
[0]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
obj metaObject() -> className()
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
QString dir
[11]
rect sceneTransform().map(QPointF(0
QGraphicsItem * item
view viewport() -> scroll(dx, dy, deviceRect)
edit hide()
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QSizePolicy policy
manager post(request, myJson, this, [this](QRestReply &reply) { if(!reply.isSuccess()) { } if(std::optional json=reply.readJson()) { } })
QJSValueList args
QJSEngine engine
[0]
\inmodule QtCore \reentrant
Definition qchar.h:18
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:962
bool contains(const AT &t) const noexcept
Definition qlist.h:45
QQuickItemChangeListener * listener
QV4::ReturnedValue fromVariant(const QVariant &)
ReturnedValue throwTypeError()
static void markObjects(QV4::Heap::Base *that, QV4::MarkStack *markStack)
static void markWrapper(QObject *object, MarkStack *markStack)
const char * sig
\inmodule QtQuick
Definition qquickitem.h:159