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