Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicktooltip.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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// Qt-Security score:significant reason:default
4
10
11#include <QtCore/qbasictimer.h>
12#include <QtQml/qqmlinfo.h>
13#include <QtQml/qqmlengine.h>
14#include <QtQml/qqmlcontext.h>
15#include <QtQml/qqmlcomponent.h>
16#include <QtQuick/qquickwindow.h>
17
19
20/*!
21 \qmltype ToolTip
22 \inherits Popup
23//! \nativetype QQuickToolTip
24 \inqmlmodule QtQuick.Controls
25 \since 5.7
26 \ingroup qtquickcontrols-popups
27 \brief Provides tool tips for any control.
28
29 A tool tip is a short piece of text that informs the user of a control's
30 function. It is typically placed above or below the parent control. The
31 tip text can be any \l{Rich Text Processing}{rich text} formatted string.
32
33 \image qtquickcontrols-tooltip.png
34 {Tooltip displaying helpful text}
35
36 \section2 Attached Tool Tips
37
38 The most straight-forward way to setup tool tips for controls is to
39 specify \l text and \l {visible}{visibility} via attached properties.
40 The following example illustrates this approach:
41
42 \snippet qtquickcontrols-tooltip.qml 1
43
44 Under normal circumstances, there is only one tool tip visible at a time.
45 In order to save resources, all items that use the ToolTip attached property
46 share the same visual tool tip label instance. Even though the visuals are
47 shared, \c text, \c timeout and \c delay are stored individually for each item
48 that uses the respective attached property. However, multiple items cannot
49 make the shared tool tip visible at the same time. The shared tool tip is only
50 shown for the last item that made it visible. The position of the shared tool
51 tip is determined by the framework.
52
53 \include qquicktooltip.qdocinc customize-note
54
55 \section2 Delay and Timeout
56
57 Tool tips are typically transient in a sense that they are shown as a
58 result of a certain external event or user interaction, and they usually
59 hide after a certain timeout. It is possible to control the delay when
60 a tool tip is shown, and the timeout when it is hidden. This makes it
61 possible to implement varying strategies for showing and hiding tool tips.
62
63 For example, on touch screens, it is a common pattern to show a tool tip
64 as a result of pressing and holding down a button. The following example
65 demonstrates how to delay showing a tool tip until the press-and-hold
66 interval is reached. In this example, the tool tip hides as soon as the
67 button is released.
68
69 \snippet qtquickcontrols-tooltip-pressandhold.qml 1
70
71 With pointer devices, however, it might be desired to show a tool tip as
72 a result of hovering a button for a while. The following example presents
73 how to show a tool tip after hovering a button for a second, and hide it
74 after a timeout of five seconds.
75
76 \snippet qtquickcontrols-tooltip-hover.qml 1
77
78 \section2 Custom Tool Tips
79
80 Should one need more fine-grained control over the tool tip position, or
81 multiple simultaneous tool tip instances are needed, it is also possible
82 to create local tool tip instances. This way, it is possible to
83 \l {Customizing ToolTip}{customize} the tool tip, and the whole \l Popup
84 API is available. The following example presents a tool tip that presents
85 the value of a slider when the handle is dragged.
86
87 \image qtquickcontrols-tooltip-slider.png
88 {Tooltip attached to slider showing current value}
89
90 \snippet qtquickcontrols-tooltip-slider.qml 1
91
92 \sa {Customizing ToolTip}, {Popup Controls},
93 {QtQuick.Controls::Popup::closePolicy}{closePolicy}
94*/
95
96// These enable auto tests to test the default behaviour of delay and timeout when using
97// the automatic policy, while also shortening their execution time.
98#ifdef QT_BUILD_INTERNAL
99Q_CONSTINIT Q_AUTOTEST_EXPORT
100#else
101// Can't be constexpr because we set it in our constructor (which we have to do because
102// toolTipWakeUpDelay() is not constexpr).
103static
104#endif
106
107#ifdef QT_BUILD_INTERNAL
108Q_CONSTINIT Q_AUTOTEST_EXPORT
109#else
110constexpr
111#endif
113
115{
116 Q_DECLARE_PUBLIC(QQuickToolTip)
117
118public:
120
122 void stopDelay();
123
126
128
129 QPalette defaultPalette() const override { return QQuickTheme::palette(QQuickTheme::ToolTip); }
130
131 int delay = 0;
132 int timeout = -1;
136};
137
138QQuickToolTipPrivate::QQuickToolTipPrivate()
139{
140 windowFlags = Qt::ToolTip;
141 if (qt_quicktooltipattachedprivate_delay == -1)
142 qt_quicktooltipattachedprivate_delay = qGuiApp->styleHints()->toolTipWakeUpDelay();
143#if QT_CONFIG(wayland)
144 extendedWindowType = QNativeInterface::Private::QWaylandWindow::ToolTip;
145#endif
146#if QT_CONFIG(xcb)
147 wmWindowType = QNativeInterface::Private::QXcbWindow::Tooltip;
148#endif
149
150}
151
153{
154 Q_Q(QQuickToolTip);
155 if (delay > 0)
156 delayTimer.start(delay, q);
157}
158
160{
161 delayTimer.stop();
162}
163
165{
166 Q_Q(QQuickToolTip);
167 if (timeout > 0)
168 timeoutTimer.start(timeout, q);
169}
170
172{
173 timeoutTimer.stop();
174}
175
177{
178 QQuickPopupPrivate::opened();
180}
181
182QQuickToolTip::QQuickToolTip(QQuickItem *parent)
183 : QQuickPopup(*(new QQuickToolTipPrivate), parent)
184{
185 Q_D(QQuickToolTip);
186 d->allowVerticalFlip = true;
187 d->allowHorizontalFlip = true;
188 d->popupItem->setHoverEnabled(false); // QTBUG-63644
189}
190
191/*!
192 \qmlproperty string QtQuick.Controls::ToolTip::text
193
194 This property holds the text shown on the tool tip.
195*/
196QString QQuickToolTip::text() const
197{
198 Q_D(const QQuickToolTip);
199 return d->text;
200}
201
202void QQuickToolTip::setText(const QString &text)
203{
204 Q_D(QQuickToolTip);
205 if (d->text == text)
206 return;
207
208 d->text = text;
209 maybeSetAccessibleName(text);
210 emit textChanged();
211}
212
213/*!
214 \qmlproperty int QtQuick.Controls::ToolTip::delay
215
216 This property holds the delay (milliseconds) after which the tool tip is
217 shown. A tooltip with a negative delay is shown immediately. The default
218 value is \c 0.
219
220 \sa {Delay and Timeout}
221*/
222int QQuickToolTip::delay() const
223{
224 Q_D(const QQuickToolTip);
225 return d->delay;
226}
227
228void QQuickToolTip::setDelay(int delay)
229{
230 Q_D(QQuickToolTip);
231 if (d->delay == delay)
232 return;
233
234 d->delay = delay;
235 emit delayChanged();
236}
237
238/*!
239 \qmlproperty int QtQuick.Controls::ToolTip::timeout
240
241 This property holds the timeout (milliseconds) after which the tool tip is
242 hidden. A tooltip with a negative timeout does not hide automatically. The
243 default value is \c -1.
244
245 \sa {Delay and Timeout}
246*/
247int QQuickToolTip::timeout() const
248{
249 Q_D(const QQuickToolTip);
250 return d->timeout;
251}
252
253void QQuickToolTip::setTimeout(int timeout)
254{
255 Q_D(QQuickToolTip);
256 if (d->timeout == timeout)
257 return;
258
259 d->timeout = timeout;
260
261 if (timeout <= 0)
262 d->stopTimeout();
263 else if (isOpened())
264 d->startTimeout();
265
266 emit timeoutChanged();
267}
268
269void QQuickToolTip::setVisible(bool visible)
270{
271 Q_D(QQuickToolTip);
272 if (visible) {
273 if (!d->visible) {
274 // We are being made visible, and we weren't before.
275 if (d->delay > 0) {
276 d->startDelay();
277 return;
278 }
279 }
280 } else {
281 d->stopDelay();
282 }
283 QQuickPopup::setVisible(visible);
284}
285
286QQuickToolTipAttached *QQuickToolTip::qmlAttachedProperties(QObject *object)
287{
288 return new QQuickToolTipAttached(object);
289}
290
291/*!
292 \since QtQuick.Controls 2.5 (Qt 5.12)
293 \qmlmethod void QtQuick.Controls::ToolTip::show(string text, int timeout)
294
295 This method shows the \a text as a tooltip, which times out in
296 \a timeout (milliseconds).
297*/
298void QQuickToolTip::show(const QString &text, int ms)
299{
300 if (ms >= 0)
301 setTimeout(ms);
302 setText(text);
303 open();
304}
305
306/*!
307 \since QtQuick.Controls 2.5 (Qt 5.12)
308 \qmlmethod void QtQuick.Controls::ToolTip::hide()
309
310 This method hides the tooltip.
311*/
312void QQuickToolTip::hide()
313{
314 close();
315}
316
317QFont QQuickToolTip::defaultFont() const
318{
319 return QQuickTheme::font(QQuickTheme::ToolTip);
320}
321
322void QQuickToolTip::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
323{
324 Q_D(QQuickToolTip);
325 QQuickPopup::itemChange(change, data);
326 if (change == QQuickItem::ItemVisibleHasChanged) {
327 if (!data.boolValue)
328 d->stopTimeout();
329
330 QQuickToolTipAttached *attached = qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(d->parentItem, false));
331 if (attached)
332 emit attached->visibleChanged();
333 }
334}
335
336void QQuickToolTip::timerEvent(QTimerEvent *event)
337{
338 Q_D(QQuickToolTip);
339 if (event->timerId() == d->timeoutTimer.timerId()) {
340 d->stopTimeout();
341 QQuickPopup::setVisible(false);
342 return;
343 }
344 if (event->timerId() == d->delayTimer.timerId()) {
345 d->stopDelay();
346 QQuickPopup::setVisible(true);
347 return;
348 }
349 QQuickPopup::timerEvent(event);
350}
351
352#if QT_CONFIG(accessibility)
353QAccessible::Role QQuickToolTip::accessibleRole() const
354{
355 return QAccessible::ToolTip;
356}
357
358void QQuickToolTip::accessibilityActiveChanged(bool active)
359{
360 Q_D(QQuickToolTip);
361 QQuickPopup::accessibilityActiveChanged(active);
362
363 if (active)
364 maybeSetAccessibleName(d->text);
365}
366#endif
367
368QQuickToolTip *QQuickToolTipAttachedPrivate::instance(bool create) const
369{
370 QQmlEngine *engine = qmlEngine(parent);
371 if (!engine)
372 return nullptr;
373
374 // QQuickAttachedPropertyPropagator uses "_q_QQuickToolTip", so we add "shared_"
375 // to make this unique.
376 static const char *name = "_q_shared_QQuickToolTip";
377
378 QQuickToolTip *tip = engine->property(name).value<QQuickToolTip *>();
379 if (!tip && create) {
380 QQmlComponent component(engine, "QtQuick.Controls", "ToolTip");
381
382 QObject *object = component.create();
383 if (object)
384 object->setParent(engine);
385
386 tip = qobject_cast<QQuickToolTip *>(object);
387 if (!tip)
388 delete object;
389 else
390 engine->setProperty(name, QVariant::fromValue(object));
391 }
392 return tip;
393}
394
395void QQuickToolTipAttachedPrivate::maybeSetVisibleImplicitly(
396 const QObject *attachee, bool visible)
397{
398 auto *toolTipAttached = qobject_cast<QQuickToolTipAttached *>(
399 qmlAttachedPropertiesObject<QQuickToolTip>(attachee, false));
400 // Not using an attached tool tip.
401 if (!toolTipAttached)
402 return;
403
404 auto *toolTipAttachedPrivate = toolTipAttached->d_func();
405 // Don't interfere if the user has set ToolTip.visible explicitly or if they've
406 // set a manual policy.
407 if (toolTipAttachedPrivate->isVisibleExplicitlySet()
408 || toolTipAttachedPrivate->policy == QQuickToolTip::Manual) {
409 return;
410 }
411
412 // Don't show ourselves if we have no text. We save calling code having to get our text and
413 // instead just test it here.
414 const bool effectiveVisible = visible ? visible && !toolTipAttachedPrivate->text.isEmpty() : false;
415 toolTipAttachedPrivate->setVisible(effectiveVisible, QQml::PropertyUtils::State::ImplicitlySet);
416}
417
418void QQuickToolTipAttachedPrivate::setVisible(bool visible, QQml::PropertyUtils::State propertyState)
419{
420 Q_Q(QQuickToolTipAttached);
421 if (warnIfAttacheeIsNotAnItem(QStringLiteral("setVisible")))
422 return;
423
424 explicitVisible = isExplicitlySet(propertyState);
425
426 if (!complete && visible) {
427 pendingShow = true;
428 return;
429 }
430
431 if (visible)
432 q->show(text);
433 else
434 q->hide();
435}
436
437bool QQuickToolTipAttachedPrivate::isVisibleExplicitlySet() const
438{
439 return explicitVisible;
440}
441
442void QQuickToolTipAttachedPrivate::setDelay(int delay, QQml::PropertyUtils::State propertyState)
443{
444 Q_Q(QQuickToolTipAttached);
445 if (warnIfAttacheeIsNotAnItem(QStringLiteral("setDelay")))
446 return;
447
448 explicitDelay = isExplicitlySet(propertyState);
449
450 if (this->delay == delay)
451 return;
452
453 this->delay = delay;
454 emit q->delayChanged();
455
456 if (q->isVisible())
457 instance(true)->setDelay(delay);
458}
459
460bool QQuickToolTipAttachedPrivate::isDelayExplicitlySet() const
461{
462 return explicitDelay;
463}
464
465void QQuickToolTipAttachedPrivate::setTimeout(int timeout, QQml::PropertyUtils::State propertyState)
466{
467 Q_Q(QQuickToolTipAttached);
468 if (warnIfAttacheeIsNotAnItem(QStringLiteral("setTimeout")))
469 return;
470
471 explicitTimeout = isExplicitlySet(propertyState);
472
473 if (this->timeout == timeout)
474 return;
475
476 this->timeout = timeout;
477 emit q->timeoutChanged();
478
479 if (q->isVisible())
480 instance(true)->setTimeout(timeout);
481}
482
483bool QQuickToolTipAttachedPrivate::isTimeoutExplicitlySet() const
484{
485 return explicitTimeout;
486}
487
488void QQuickToolTipAttachedPrivate::inheritPolicy(QQuickToolTip::Policy policy)
489{
490 Q_Q(QQuickToolTipAttached);
491 if (this->policy == policy)
492 return;
493
494 this->policy = policy;
495 propagatePolicy();
496 emit q->policyChanged();
497}
498
499void QQuickToolTipAttachedPrivate::propagatePolicy()
500{
501 Q_Q(QQuickToolTipAttached);
502 const auto attachedToolTipChildren = q->attachedChildren();
503 for (QtPrivate::QQuickAttachedPropertyPropagator *child : attachedToolTipChildren) {
504 auto *attachedToolTipChild = qobject_cast<QQuickToolTipAttached *>(child);
505 if (attachedToolTipChild)
506 attachedToolTipChild->d_func()->inheritPolicy(policy);
507 }
508}
509
510/*!
511 \internal
512
513 We used to warn that the ToolTip attached property must be attached to an object deriving
514 from Item. That made sense before the introduction of ToolTip.policy, but now we need to
515 be able to set a policy on e.g. ApplicationWindow and have it propagate down to the rest
516 of the scene. So instead of warning in the constructor, we warn in the individual functions.
517*/
518bool QQuickToolTipAttachedPrivate::warnIfAttacheeIsNotAnItem(const QString &functionName)
519{
520 QQuickItem *item = qobject_cast<QQuickItem *>(parent);
521 if (Q_LIKELY(item))
522 return false;
523
524 qmlWarning(parent).nospace().noquote() << "The attached function ToolTip::" << functionName
525 << " can only be called when the attachee derives from Item";
526 return true;
527}
528
529int QQuickToolTipAttachedPrivate::calculateTimeout(const QString &text)
530{
531 if (Q_UNLIKELY(qt_quicktooltipattachedprivate_short_timeout)) {
532 // For auto tests, to ensure that the default automatic timeout works.
533 return 123;
534 }
535
536 // Based on QTipLabel::restartExpireTimer.
537 return 10000 + 40 * qMax(0, text.length() - 100);
538}
539
540QQuickToolTipAttached::QQuickToolTipAttached(QObject *parent)
541 : QtPrivate::QQuickAttachedPropertyPropagator(*(new QQuickToolTipAttachedPrivate), parent)
542{
543 initialize();
544}
545
546/*!
547 \qmlattachedproperty string QtQuick.Controls::ToolTip::text
548
549 This attached property holds the text of the shared tool tip.
550 The property can be attached to any item.
551
552 \sa {Attached Tool Tips}
553*/
554QString QQuickToolTipAttached::text() const
555{
556 Q_D(const QQuickToolTipAttached);
557 return d->text;
558}
559
560void QQuickToolTipAttached::setText(const QString &text)
561{
562 Q_D(QQuickToolTipAttached);
563 if (d->warnIfAttacheeIsNotAnItem(QStringLiteral("setText")))
564 return;
565 if (d->text == text)
566 return;
567
568 d->text = text;
569 emit textChanged();
570
571 if (isVisible())
572 d->instance(true)->setText(text);
573}
574
575/*!
576 \qmlattachedproperty int QtQuick.Controls::ToolTip::delay
577
578 This attached property holds the delay (milliseconds) of the shared tool tip.
579 The property can be attached to any item.
580
581 The default value is \c 0 if \l policy is \c ToolTip.Manual, otherwise it
582 is \l QStyleHints::toolTipWakeUpDelay().
583
584 \sa {Attached Tool Tips}, {Delay and Timeout}
585*/
586int QQuickToolTipAttached::delay() const
587{
588 Q_D(const QQuickToolTipAttached);
589 return d->explicitDelay || d->policy == QQuickToolTip::Manual ? d->delay
590 : qt_quicktooltipattachedprivate_delay;
591}
592
593void QQuickToolTipAttached::setDelay(int delay)
594{
595 Q_D(QQuickToolTipAttached);
596 d->setDelay(delay, QQml::PropertyUtils::State::ExplicitlySet);
597}
598
599/*!
600 \qmlattachedproperty int QtQuick.Controls::ToolTip::timeout
601
602 This attached property holds the timeout (milliseconds) of the shared tool tip.
603 The property can be attached to any item.
604
605 The default value is based on the length of the text, and will always be
606 at least 10 seconds long.
607
608 \sa {Attached Tool Tips}, {Delay and Timeout}
609*/
610int QQuickToolTipAttached::timeout() const
611{
612 Q_D(const QQuickToolTipAttached);
613 return d->explicitTimeout || d->policy == QQuickToolTip::Manual ? d->timeout
614 : d->calculateTimeout(d->text);
615}
616
617void QQuickToolTipAttached::setTimeout(int timeout)
618{
619 Q_D(QQuickToolTipAttached);
620 d->setTimeout(timeout, QQml::PropertyUtils::State::ExplicitlySet);
621}
622
623/*!
624 \qmlattachedproperty bool QtQuick.Controls::ToolTip::visible
625
626 This attached property holds whether the shared tool tip is visible.
627 The property can be attached to any item.
628
629 \sa {Attached Tool Tips}
630*/
631bool QQuickToolTipAttached::isVisible() const
632{
633 Q_D(const QQuickToolTipAttached);
634 QQuickToolTip *tip = d->instance(false);
635 if (!tip)
636 return false;
637
638 return tip->isVisible() && tip->parentItem() == parent();
639}
640
641void QQuickToolTipAttached::setVisible(bool visible)
642{
643 Q_D(QQuickToolTipAttached);
644 d->setVisible(visible, QQml::PropertyUtils::State::ExplicitlySet);
645}
646
647/*!
648 \qmlattachedproperty ToolTip QtQuick.Controls::ToolTip::toolTip
649
650 This attached property holds the shared tool tip instance. The property
651 can be attached to any item.
652
653 \sa {Attached Tool Tips}
654*/
655QQuickToolTip *QQuickToolTipAttached::toolTip() const
656{
657 Q_D(const QQuickToolTipAttached);
658 return d->instance(true);
659}
660
661/*!
662 \qmlattachedproperty enumeration QtQuick.Controls::ToolTip::policy
663 \since 6.12
664
665 This attached property controls whether the visibility of the
666 \l {toolTip}{shared tool tip instance} is handled automatically.
667 It only has an effect for items on which \c ToolTip.visible \e {has not}
668 been set. Only items that set \c ToolTip.text will be made visible. It only
669 has an effect for the following items and their derived types: \l Control,
670 \l TextArea and \l TextField. All other types require \l visible to be
671 manually set.
672
673 It also determines the default values for the delay and timeout properties
674 of the shared tool tip instance (regardless of whether \c ToolTip.visible
675 or \c ToolTip.text have been set).
676
677 This property is propagated to attached ToolTip children.
678
679 Available values:
680 \value ToolTip.Automatic The shared tool tip will be shown when the
681 attachee is hovered or long-pressed (if triggered by touch and the
682 attachee is an \l AbstractButton or one of its derived types). If
683 the visible property has been explicitly set, or the text property has
684 not been set, this value has no effect, and the behavior will be
685 equivalent to \c ToolTip.Manual.
686 The shared tool tip will also default to platform-specific values
687 for its delay and timeout properties.
688 \value ToolTip.Manual The shared tool tip will not be shown automatically,
689 and the developer is responsible for setting the visible property.
690 The shared tool tip will not default to platform-specific values
691 for its delay and timeout properties.
692
693 The default value is \c {ToolTip.Automatic}.
694
695 The property provides a way to opt-out of the default values for shared
696 tool tips introduced in Qt 6.12. This is particularly relevant for legacy
697 code that doesn't explicitly set the visible property before an item is
698 interacted with. For applications that declaratively set the visible
699 property and find the new default values for delay and timeout acceptable,
700 \c policy is not needed.
701
702 \sa {Attached Tool Tips}
703*/
704QQuickToolTip::Policy QQuickToolTipAttached::policy() const
705{
706 Q_D(const QQuickToolTipAttached);
707 return d->policy;
708}
709
710void QQuickToolTipAttached::setVisiblePolicy(QQuickToolTip::Policy policy)
711{
712 Q_D(QQuickToolTipAttached);
713 if (d->policy == policy)
714 return;
715
716 d->policy = policy;
717 d->propagatePolicy();
718 emit policyChanged();
719}
720
721void QQuickToolTipAttached::resetVisiblePolicy()
722{
723 setVisiblePolicy(QQuickToolTip::Automatic);
724}
725
726/*!
727 \qmlattachedmethod void QtQuick.Controls::ToolTip::show(string text, int timeout = -1)
728
729 This attached method shows the shared tooltip with \a text and \a timeout (milliseconds).
730 The method can be attached to any item.
731
732 \sa {Attached Tool Tips}
733*/
734void QQuickToolTipAttached::show(const QString &text, int ms)
735{
736 Q_D(QQuickToolTipAttached);
737 if (d->warnIfAttacheeIsNotAnItem(QStringLiteral("show")))
738 return;
739
740 QQuickToolTip *tip = d->instance(true);
741 if (!tip)
742 return;
743
744 tip->resetWidth();
745 tip->resetHeight();
746 tip->setParentItem(qobject_cast<QQuickItem *>(parent()));
747 tip->setDelay(delay());
748 tip->setTimeout(ms >= 0 ? ms : timeout());
749 tip->show(text);
750}
751
752/*!
753 \qmlattachedmethod void QtQuick.Controls::ToolTip::hide()
754
755 This attached method hides the shared tooltip. The method can be attached to any item.
756
757 \sa {Attached Tool Tips}
758*/
759void QQuickToolTipAttached::hide()
760{
761 Q_D(QQuickToolTipAttached);
762 QQuickToolTip *tip = d->instance(false);
763 if (!tip)
764 return;
765 // check the parent item to prevent unexpectedly closing tooltip by new created invisible tooltip
766 if (parent() == tip->parentItem())
767 tip->close();
768}
769
770void QQuickToolTipAttached::attachedParentChange(QQuickAttachedPropertyPropagator *newParent,
771 QQuickAttachedPropertyPropagator */*oldParent*/)
772{
773 auto *attachedToolTipParent = qobject_cast<QQuickToolTipAttached *>(newParent);
774 if (!attachedToolTipParent)
775 return;
776
777 Q_D(QQuickToolTipAttached);
778 d->inheritPolicy(attachedToolTipParent->policy());
779}
780
781void QQuickToolTipAttached::classBegin()
782{
783 Q_D(QQuickToolTipAttached);
784 d->complete = false;
785}
786
787void QQuickToolTipAttached::componentComplete()
788{
789 Q_D(QQuickToolTipAttached);
790 d->complete = true;
791
792 if (d->pendingShow) {
793 d->pendingShow = false;
794 show(d->text);
795 }
796}
797
798QT_END_NAMESPACE
799
800#include "moc_qquicktooltip_p.cpp"
QPalette defaultPalette() const override
void opened() override
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE int qt_quicktooltipattachedprivate_delay
Provides tool tips for any control.
constexpr bool qt_quicktooltipattachedprivate_short_timeout