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}
147
149{
150 Q_Q(QQuickToolTip);
151 if (delay > 0)
152 delayTimer.start(delay, q);
153}
154
156{
157 delayTimer.stop();
158}
159
161{
162 Q_Q(QQuickToolTip);
163 if (timeout > 0)
164 timeoutTimer.start(timeout, q);
165}
166
168{
169 timeoutTimer.stop();
170}
171
173{
174 QQuickPopupPrivate::opened();
176}
177
178QQuickToolTip::QQuickToolTip(QQuickItem *parent)
179 : QQuickPopup(*(new QQuickToolTipPrivate), parent)
180{
181 Q_D(QQuickToolTip);
182 d->allowVerticalFlip = true;
183 d->allowHorizontalFlip = true;
184 d->popupItem->setHoverEnabled(false); // QTBUG-63644
185}
186
187/*!
188 \qmlproperty string QtQuick.Controls::ToolTip::text
189
190 This property holds the text shown on the tool tip.
191*/
192QString QQuickToolTip::text() const
193{
194 Q_D(const QQuickToolTip);
195 return d->text;
196}
197
198void QQuickToolTip::setText(const QString &text)
199{
200 Q_D(QQuickToolTip);
201 if (d->text == text)
202 return;
203
204 d->text = text;
205 maybeSetAccessibleName(text);
206 emit textChanged();
207}
208
209/*!
210 \qmlproperty int QtQuick.Controls::ToolTip::delay
211
212 This property holds the delay (milliseconds) after which the tool tip is
213 shown. A tooltip with a negative delay is shown immediately. The default
214 value is \c 0.
215
216 \sa {Delay and Timeout}
217*/
218int QQuickToolTip::delay() const
219{
220 Q_D(const QQuickToolTip);
221 return d->delay;
222}
223
224void QQuickToolTip::setDelay(int delay)
225{
226 Q_D(QQuickToolTip);
227 if (d->delay == delay)
228 return;
229
230 d->delay = delay;
231 emit delayChanged();
232}
233
234/*!
235 \qmlproperty int QtQuick.Controls::ToolTip::timeout
236
237 This property holds the timeout (milliseconds) after which the tool tip is
238 hidden. A tooltip with a negative timeout does not hide automatically. The
239 default value is \c -1.
240
241 \sa {Delay and Timeout}
242*/
243int QQuickToolTip::timeout() const
244{
245 Q_D(const QQuickToolTip);
246 return d->timeout;
247}
248
249void QQuickToolTip::setTimeout(int timeout)
250{
251 Q_D(QQuickToolTip);
252 if (d->timeout == timeout)
253 return;
254
255 d->timeout = timeout;
256
257 if (timeout <= 0)
258 d->stopTimeout();
259 else if (isOpened())
260 d->startTimeout();
261
262 emit timeoutChanged();
263}
264
265void QQuickToolTip::setVisible(bool visible)
266{
267 Q_D(QQuickToolTip);
268 if (visible) {
269 if (!d->visible) {
270 // We are being made visible, and we weren't before.
271 if (d->delay > 0) {
272 d->startDelay();
273 return;
274 }
275 }
276 } else {
277 d->stopDelay();
278 }
279 QQuickPopup::setVisible(visible);
280}
281
282QQuickToolTipAttached *QQuickToolTip::qmlAttachedProperties(QObject *object)
283{
284 return new QQuickToolTipAttached(object);
285}
286
287/*!
288 \since QtQuick.Controls 2.5 (Qt 5.12)
289 \qmlmethod void QtQuick.Controls::ToolTip::show(string text, int timeout)
290
291 This method shows the \a text as a tooltip, which times out in
292 \a timeout (milliseconds).
293*/
294void QQuickToolTip::show(const QString &text, int ms)
295{
296 if (ms >= 0)
297 setTimeout(ms);
298 setText(text);
299 open();
300}
301
302/*!
303 \since QtQuick.Controls 2.5 (Qt 5.12)
304 \qmlmethod void QtQuick.Controls::ToolTip::hide()
305
306 This method hides the tooltip.
307*/
308void QQuickToolTip::hide()
309{
310 close();
311}
312
313QFont QQuickToolTip::defaultFont() const
314{
315 return QQuickTheme::font(QQuickTheme::ToolTip);
316}
317
318void QQuickToolTip::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
319{
320 Q_D(QQuickToolTip);
321 QQuickPopup::itemChange(change, data);
322 if (change == QQuickItem::ItemVisibleHasChanged) {
323 if (!data.boolValue)
324 d->stopTimeout();
325
326 QQuickToolTipAttached *attached = qobject_cast<QQuickToolTipAttached *>(qmlAttachedPropertiesObject<QQuickToolTip>(d->parentItem, false));
327 if (attached)
328 emit attached->visibleChanged();
329 }
330}
331
332void QQuickToolTip::timerEvent(QTimerEvent *event)
333{
334 Q_D(QQuickToolTip);
335 if (event->timerId() == d->timeoutTimer.timerId()) {
336 d->stopTimeout();
337 QQuickPopup::setVisible(false);
338 return;
339 }
340 if (event->timerId() == d->delayTimer.timerId()) {
341 d->stopDelay();
342 QQuickPopup::setVisible(true);
343 return;
344 }
345 QQuickPopup::timerEvent(event);
346}
347
348#if QT_CONFIG(accessibility)
349QAccessible::Role QQuickToolTip::accessibleRole() const
350{
351 return QAccessible::ToolTip;
352}
353
354void QQuickToolTip::accessibilityActiveChanged(bool active)
355{
356 Q_D(QQuickToolTip);
357 QQuickPopup::accessibilityActiveChanged(active);
358
359 if (active)
360 maybeSetAccessibleName(d->text);
361}
362#endif
363
364QQuickToolTip *QQuickToolTipAttachedPrivate::instance(bool create) const
365{
366 QQmlEngine *engine = qmlEngine(parent);
367 if (!engine)
368 return nullptr;
369
370 // QQuickAttachedPropertyPropagator uses "_q_QQuickToolTip", so we add "shared_"
371 // to make this unique.
372 static const char *name = "_q_shared_QQuickToolTip";
373
374 QQuickToolTip *tip = engine->property(name).value<QQuickToolTip *>();
375 if (!tip && create) {
376 QQmlComponent component(engine, "QtQuick.Controls", "ToolTip");
377
378 QObject *object = component.create();
379 if (object)
380 object->setParent(engine);
381
382 tip = qobject_cast<QQuickToolTip *>(object);
383 if (!tip)
384 delete object;
385 else
386 engine->setProperty(name, QVariant::fromValue(object));
387 }
388 return tip;
389}
390
391void QQuickToolTipAttachedPrivate::maybeSetVisibleImplicitly(
392 const QObject *attachee, bool visible)
393{
394 auto *toolTipAttached = qobject_cast<QQuickToolTipAttached *>(
395 qmlAttachedPropertiesObject<QQuickToolTip>(attachee, false));
396 // Not using an attached tool tip.
397 if (!toolTipAttached)
398 return;
399
400 auto *toolTipAttachedPrivate = toolTipAttached->d_func();
401 // Don't interfere if the user has set ToolTip.visible explicitly or if they've
402 // set a manual policy.
403 if (toolTipAttachedPrivate->isVisibleExplicitlySet()
404 || toolTipAttachedPrivate->policy == QQuickToolTip::Manual) {
405 return;
406 }
407
408 // Don't show ourselves if we have no text. We save calling code having to get our text and
409 // instead just test it here.
410 const bool effectiveVisible = visible ? visible && !toolTipAttachedPrivate->text.isEmpty() : false;
411 toolTipAttachedPrivate->setVisible(effectiveVisible, QQml::PropertyUtils::State::ImplicitlySet);
412}
413
414void QQuickToolTipAttachedPrivate::setVisible(bool visible, QQml::PropertyUtils::State propertyState)
415{
416 Q_Q(QQuickToolTipAttached);
417 if (warnIfAttacheeIsNotAnItem(QStringLiteral("setVisible")))
418 return;
419
420 explicitVisible = isExplicitlySet(propertyState);
421
422 if (!complete && visible) {
423 pendingShow = true;
424 return;
425 }
426
427 if (visible)
428 q->show(text);
429 else
430 q->hide();
431}
432
433bool QQuickToolTipAttachedPrivate::isVisibleExplicitlySet() const
434{
435 return explicitVisible;
436}
437
438void QQuickToolTipAttachedPrivate::setDelay(int delay, QQml::PropertyUtils::State propertyState)
439{
440 Q_Q(QQuickToolTipAttached);
441 if (warnIfAttacheeIsNotAnItem(QStringLiteral("setDelay")))
442 return;
443
444 explicitDelay = isExplicitlySet(propertyState);
445
446 if (this->delay == delay)
447 return;
448
449 this->delay = delay;
450 emit q->delayChanged();
451
452 if (q->isVisible())
453 instance(true)->setDelay(delay);
454}
455
456bool QQuickToolTipAttachedPrivate::isDelayExplicitlySet() const
457{
458 return explicitDelay;
459}
460
461void QQuickToolTipAttachedPrivate::setTimeout(int timeout, QQml::PropertyUtils::State propertyState)
462{
463 Q_Q(QQuickToolTipAttached);
464 if (warnIfAttacheeIsNotAnItem(QStringLiteral("setTimeout")))
465 return;
466
467 explicitTimeout = isExplicitlySet(propertyState);
468
469 if (this->timeout == timeout)
470 return;
471
472 this->timeout = timeout;
473 emit q->timeoutChanged();
474
475 if (q->isVisible())
476 instance(true)->setTimeout(timeout);
477}
478
479bool QQuickToolTipAttachedPrivate::isTimeoutExplicitlySet() const
480{
481 return explicitTimeout;
482}
483
484void QQuickToolTipAttachedPrivate::inheritPolicy(QQuickToolTip::Policy policy)
485{
486 Q_Q(QQuickToolTipAttached);
487 if (this->policy == policy)
488 return;
489
490 this->policy = policy;
491 propagatePolicy();
492 emit q->policyChanged();
493}
494
495void QQuickToolTipAttachedPrivate::propagatePolicy()
496{
497 Q_Q(QQuickToolTipAttached);
498 const auto attachedToolTipChildren = q->attachedChildren();
499 for (QtPrivate::QQuickAttachedPropertyPropagator *child : attachedToolTipChildren) {
500 auto *attachedToolTipChild = qobject_cast<QQuickToolTipAttached *>(child);
501 if (attachedToolTipChild)
502 attachedToolTipChild->d_func()->inheritPolicy(policy);
503 }
504}
505
506/*!
507 \internal
508
509 We used to warn that the ToolTip attached property must be attached to an object deriving
510 from Item. That made sense before the introduction of ToolTip.policy, but now we need to
511 be able to set a policy on e.g. ApplicationWindow and have it propagate down to the rest
512 of the scene. So instead of warning in the constructor, we warn in the individual functions.
513*/
514bool QQuickToolTipAttachedPrivate::warnIfAttacheeIsNotAnItem(const QString &functionName)
515{
516 QQuickItem *item = qobject_cast<QQuickItem *>(parent);
517 if (Q_LIKELY(item))
518 return false;
519
520 qmlWarning(parent).nospace().noquote() << "The attached function ToolTip::" << functionName
521 << " can only be called when the attachee derives from Item";
522 return true;
523}
524
525int QQuickToolTipAttachedPrivate::calculateTimeout(const QString &text)
526{
527 if (Q_UNLIKELY(qt_quicktooltipattachedprivate_short_timeout)) {
528 // For auto tests, to ensure that the default automatic timeout works.
529 return 123;
530 }
531
532 // Based on QTipLabel::restartExpireTimer.
533 return 10000 + 40 * qMax(0, text.length() - 100);
534}
535
536QQuickToolTipAttached::QQuickToolTipAttached(QObject *parent)
537 : QtPrivate::QQuickAttachedPropertyPropagator(*(new QQuickToolTipAttachedPrivate), parent)
538{
539 initialize();
540}
541
542/*!
543 \qmlattachedproperty string QtQuick.Controls::ToolTip::text
544
545 This attached property holds the text of the shared tool tip.
546 The property can be attached to any item.
547
548 \sa {Attached Tool Tips}
549*/
550QString QQuickToolTipAttached::text() const
551{
552 Q_D(const QQuickToolTipAttached);
553 return d->text;
554}
555
556void QQuickToolTipAttached::setText(const QString &text)
557{
558 Q_D(QQuickToolTipAttached);
559 if (d->warnIfAttacheeIsNotAnItem(QStringLiteral("setText")))
560 return;
561 if (d->text == text)
562 return;
563
564 d->text = text;
565 emit textChanged();
566
567 if (isVisible())
568 d->instance(true)->setText(text);
569}
570
571/*!
572 \qmlattachedproperty int QtQuick.Controls::ToolTip::delay
573
574 This attached property holds the delay (milliseconds) of the shared tool tip.
575 The property can be attached to any item.
576
577 The default value is \c 0 if \l policy is \c ToolTip.Manual, otherwise it
578 is \l QStyleHints::toolTipWakeUpDelay().
579
580 \sa {Attached Tool Tips}, {Delay and Timeout}
581*/
582int QQuickToolTipAttached::delay() const
583{
584 Q_D(const QQuickToolTipAttached);
585 return d->explicitDelay || d->policy == QQuickToolTip::Manual ? d->delay
586 : qt_quicktooltipattachedprivate_delay;
587}
588
589void QQuickToolTipAttached::setDelay(int delay)
590{
591 Q_D(QQuickToolTipAttached);
592 d->setDelay(delay, QQml::PropertyUtils::State::ExplicitlySet);
593}
594
595/*!
596 \qmlattachedproperty int QtQuick.Controls::ToolTip::timeout
597
598 This attached property holds the timeout (milliseconds) of the shared tool tip.
599 The property can be attached to any item.
600
601 The default value is based on the length of the text, and will always be
602 at least 10 seconds long.
603
604 \sa {Attached Tool Tips}, {Delay and Timeout}
605*/
606int QQuickToolTipAttached::timeout() const
607{
608 Q_D(const QQuickToolTipAttached);
609 return d->explicitTimeout || d->policy == QQuickToolTip::Manual ? d->timeout
610 : d->calculateTimeout(d->text);
611}
612
613void QQuickToolTipAttached::setTimeout(int timeout)
614{
615 Q_D(QQuickToolTipAttached);
616 d->setTimeout(timeout, QQml::PropertyUtils::State::ExplicitlySet);
617}
618
619/*!
620 \qmlattachedproperty bool QtQuick.Controls::ToolTip::visible
621
622 This attached property holds whether the shared tool tip is visible.
623 The property can be attached to any item.
624
625 \sa {Attached Tool Tips}
626*/
627bool QQuickToolTipAttached::isVisible() const
628{
629 Q_D(const QQuickToolTipAttached);
630 QQuickToolTip *tip = d->instance(false);
631 if (!tip)
632 return false;
633
634 return tip->isVisible() && tip->parentItem() == parent();
635}
636
637void QQuickToolTipAttached::setVisible(bool visible)
638{
639 Q_D(QQuickToolTipAttached);
640 d->setVisible(visible, QQml::PropertyUtils::State::ExplicitlySet);
641}
642
643/*!
644 \qmlattachedproperty ToolTip QtQuick.Controls::ToolTip::toolTip
645
646 This attached property holds the shared tool tip instance. The property
647 can be attached to any item.
648
649 \sa {Attached Tool Tips}
650*/
651QQuickToolTip *QQuickToolTipAttached::toolTip() const
652{
653 Q_D(const QQuickToolTipAttached);
654 return d->instance(true);
655}
656
657/*!
658 \qmlattachedproperty enumeration QtQuick.Controls::ToolTip::policy
659 \since 6.12
660
661 This attached property controls whether the visibility of the
662 \l {toolTip}{shared tool tip instance} is handled automatically.
663 It only has an effect for items on which \c ToolTip.visible \e {has not}
664 been set. Only items that set \c ToolTip.text will be made visible. It only
665 has an effect for the following items and their derived types: \l Control,
666 \l TextArea and \l TextField. All other types require \l visible to be
667 manually set.
668
669 It also determines the default values for the delay and timeout properties
670 of the shared tool tip instance (regardless of whether \c ToolTip.visible
671 or \c ToolTip.text have been set).
672
673 This property is propagated to attached ToolTip children.
674
675 Available values:
676 \value ToolTip.Automatic The shared tool tip will be shown when the
677 attachee is hovered or long-pressed (if triggered by touch and the
678 attachee is an \l AbstractButton or one of its derived types). If
679 the visible property has been explicitly set, or the text property has
680 not been set, this value has no effect, and the behavior will be
681 equivalent to \c ToolTip.Manual.
682
683 The shared tool tip will also default to platform-specific values
684 for its delay and timeout properties.
685 \value ToolTip.Manual The shared tool tip will not be shown automatically,
686 and the developer is responsible for setting the visible property.
687
688 The shared tool tip will not default to platform-specific values
689 for its delay and timeout properties.
690
691 The default value is \c {ToolTip.Automatic}.
692
693 The property provides a way to opt-out of the default values for shared
694 tool tips introduced in Qt 6.12. This is particularly relevant for legacy
695 code that doesn't explicitly set the visible property before an item is
696 interacted with. For applications that declaratively set the visible
697 property and find the new default values for delay and timeout acceptable,
698 \c policy is not needed.
699
700 \sa {Attached Tool Tips}
701*/
702QQuickToolTip::Policy QQuickToolTipAttached::policy() const
703{
704 Q_D(const QQuickToolTipAttached);
705 return d->policy;
706}
707
708void QQuickToolTipAttached::setVisiblePolicy(QQuickToolTip::Policy policy)
709{
710 Q_D(QQuickToolTipAttached);
711 if (d->policy == policy)
712 return;
713
714 d->policy = policy;
715 d->propagatePolicy();
716 emit policyChanged();
717}
718
719void QQuickToolTipAttached::resetVisiblePolicy()
720{
721 setVisiblePolicy(QQuickToolTip::Automatic);
722}
723
724/*!
725 \qmlattachedmethod void QtQuick.Controls::ToolTip::show(string text, int timeout = -1)
726
727 This attached method shows the shared tooltip with \a text and \a timeout (milliseconds).
728 The method can be attached to any item.
729
730 \sa {Attached Tool Tips}
731*/
732void QQuickToolTipAttached::show(const QString &text, int ms)
733{
734 Q_D(QQuickToolTipAttached);
735 if (d->warnIfAttacheeIsNotAnItem(QStringLiteral("show")))
736 return;
737
738 QQuickToolTip *tip = d->instance(true);
739 if (!tip)
740 return;
741
742 tip->resetWidth();
743 tip->resetHeight();
744 tip->setParentItem(qobject_cast<QQuickItem *>(parent()));
745 tip->setDelay(delay());
746 tip->setTimeout(ms >= 0 ? ms : timeout());
747 tip->show(text);
748}
749
750/*!
751 \qmlattachedmethod void QtQuick.Controls::ToolTip::hide()
752
753 This attached method hides the shared tooltip. The method can be attached to any item.
754
755 \sa {Attached Tool Tips}
756*/
757void QQuickToolTipAttached::hide()
758{
759 Q_D(QQuickToolTipAttached);
760 QQuickToolTip *tip = d->instance(false);
761 if (!tip)
762 return;
763 // check the parent item to prevent unexpectedly closing tooltip by new created invisible tooltip
764 if (parent() == tip->parentItem())
765 tip->close();
766}
767
768void QQuickToolTipAttached::attachedParentChange(QQuickAttachedPropertyPropagator *newParent,
769 QQuickAttachedPropertyPropagator */*oldParent*/)
770{
771 auto *attachedToolTipParent = qobject_cast<QQuickToolTipAttached *>(newParent);
772 if (!attachedToolTipParent)
773 return;
774
775 Q_D(QQuickToolTipAttached);
776 d->inheritPolicy(attachedToolTipParent->policy());
777}
778
779void QQuickToolTipAttached::classBegin()
780{
781 Q_D(QQuickToolTipAttached);
782 d->complete = false;
783}
784
785void QQuickToolTipAttached::componentComplete()
786{
787 Q_D(QQuickToolTipAttached);
788 d->complete = true;
789
790 if (d->pendingShow) {
791 d->pendingShow = false;
792 show(d->text);
793 }
794}
795
796QT_END_NAMESPACE
797
798#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