From 134d3592b7811a0b93f02447677e1379968e2f58 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 23 Oct 2023 18:09:47 +0200 Subject: [PATCH] Convert tooltips example to snippets The important bits from the example are ~10 lines of code, no need for building a poor-man's version of a graphics or item view. Change-Id: I7874c66765c5b46230c92846ee3de1ee83f47e45 Reviewed-by: Oliver Eftevaag (cherry picked from commit ae39b1634556f82fe5d7505ed9b6ebb883d6f813) Reviewed-by: Qt Cherry-pick Bot --- doc/src/images/tooltips-example.png | Bin 12479 -> 0 bytes examples/widgets/doc/src/tooltips.qdoc | 375 ------------------ examples/widgets/widgets/CMakeLists.txt | 1 - .../widgets/widgets/tooltips/CMakeLists.txt | 52 --- .../widgets/tooltips/images/circle.png | Bin 165 -> 0 bytes .../widgets/tooltips/images/square.png | Bin 94 -> 0 bytes .../widgets/tooltips/images/triangle.png | Bin 170 -> 0 bytes examples/widgets/widgets/tooltips/main.cpp | 14 - .../widgets/widgets/tooltips/shapeitem.cpp | 60 --- examples/widgets/widgets/tooltips/shapeitem.h | 33 -- .../widgets/widgets/tooltips/sortingbox.cpp | 277 ------------- .../widgets/widgets/tooltips/sortingbox.h | 71 ---- .../widgets/widgets/tooltips/tooltips.pro | 12 - .../widgets/widgets/tooltips/tooltips.qrc | 7 - examples/widgets/widgets/widgets.pro | 1 - src/widgets/doc/snippets/tooltips/main.cpp | 74 ++++ src/widgets/kernel/qtooltip.cpp | 19 +- 17 files changed, 88 insertions(+), 908 deletions(-) delete mode 100644 doc/src/images/tooltips-example.png delete mode 100644 examples/widgets/doc/src/tooltips.qdoc delete mode 100644 examples/widgets/widgets/tooltips/CMakeLists.txt delete mode 100644 examples/widgets/widgets/tooltips/images/circle.png delete mode 100644 examples/widgets/widgets/tooltips/images/square.png delete mode 100644 examples/widgets/widgets/tooltips/images/triangle.png delete mode 100644 examples/widgets/widgets/tooltips/main.cpp delete mode 100644 examples/widgets/widgets/tooltips/shapeitem.cpp delete mode 100644 examples/widgets/widgets/tooltips/shapeitem.h delete mode 100644 examples/widgets/widgets/tooltips/sortingbox.cpp delete mode 100644 examples/widgets/widgets/tooltips/sortingbox.h delete mode 100644 examples/widgets/widgets/tooltips/tooltips.pro delete mode 100644 examples/widgets/widgets/tooltips/tooltips.qrc create mode 100644 src/widgets/doc/snippets/tooltips/main.cpp diff --git a/doc/src/images/tooltips-example.png b/doc/src/images/tooltips-example.png deleted file mode 100644 index f2236b43de4e06cc1101305a4cdb6315f77a87a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12479 zcmajGc|4T;7e7p7sVos$(zJ<)lr8&~ahDLeDbtu#vP?|NSi+c4ma?RhO4dn~W|WMv z&LmqAW^9vnLNbiq*k;Vk?;7s=_r0Iz`Qv$c@tV1=bI$cX=e*DPY?p*{j&>5;l(q>7 z2uPg%>y(RtfZ#gt`RZ6huW9$$&urSnep()iJ$NsAr*wss)iax;{+ddu_JVR^PpHcQasl|fX$W>#0Nl(O zBDl4Eg{1h?v4lD`bE#dIL>pg8_+0h*vsVbG?HW-IJe&CAhNN`J4Ow??2C%&5q8Hz3~}D+Pw9pA%=H(#?i(CFJ>xEQ*UaWwHRH{;-)k zSL?ebqhV#io^c5&CIxiXx5kyGkGor_0GdQVvxTo&(UOfMgj4=}Us37t%z|-{yZ#R8 z9Cin3p+BE7G`*wob1d;vRd#my6&gZcn?_w%SMsP6#f;e(3UdTCm&^OFwxRB>fSe5( zf3~&;DtsAB(2%-yH*%@d*>#YFS|4-TyVfE)9u0LI60%!OI99V5)i}m}1+uj%Qd8hi zWfLb=*QefEZ+$Udw27La${? z>1m^XPNH;!P20B*-xVp2@TX7K#JE>9OU;*ti688l8Gn#?i2wr0PZs?BMd4%CW!Gc1 zPgl?2kL?ft(_uW}uvS3L@Z<-}#%(%?;55%^<{1r`cgmMdn4BP7zIeN{>{8aRjEI78 z5vpm!N>O%lo@e-Q2VsZzlG!5=dVciSG4=jGKIYupJvL380Sgr4jvSen-Z)k?4r8wJ z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OmZj(x?XJWt&A{cQlqe9%U^@Ne)jg zww?c9)g5%RhIxIGXR`B1Y)ZSn@CGPL(5D@&@#r0QA2p8ur$RSn{r>4Jc1L5lK5||& z8O!_z$uG4}3aslQ|9;*F>_Y6ItpNKF>Lk5?V=M8`q}TC5WZd&aUA>!Ccp>J_@4#z+ zlB@!!?5sz=k|gLCVScyXVgus8)+kLkoU-IBP`(88NdQZgQ#a{XL0gvh?-Lu@2P`l6 z?>GX>{4M`KALBpgl0xewiBWm#56@fz*KB85aG0_@QT}U}#2xEAQ9l_A_RUdG0`QLs O0;g>qPvNXDNBE|FfWW@y19uUWxiU!g3BtkK&G8{GrDrv|VXIA-9r9 zfvTPJAKo2O?-f}D92jg}L>Ow1iwFxI_3?82X^{}g&kL1rUj^FB N;OXk;vd$@?2>@XMHh=&C diff --git a/examples/widgets/widgets/tooltips/images/square.png b/examples/widgets/widgets/tooltips/images/square.png deleted file mode 100644 index c0fd2d540abc41bc4b3a1d40c50280d9c4682667..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 94 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnL3?x0byx0z;*aCb)T!D1NivK+#@~eR?VNVyw o5RU7~2@H+D{{R2aYsbXG(CeF#eSSw@8&I0T)78&qol`;+0MUXOJOBUy diff --git a/examples/widgets/widgets/tooltips/images/triangle.png b/examples/widgets/widgets/tooltips/images/triangle.png deleted file mode 100644 index 2ee15f8f1f569b2eaf9405d7e6fa709728835b73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJLQfaRkch)?&v|n-7znUjl)0>2 zby~1#M?lh~pI6hQs$$n~jXG<#^Zb$i;9s0agqI6wJP - -#include "sortingbox.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - SortingBox sortingBox; - sortingBox.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/tooltips/shapeitem.cpp b/examples/widgets/widgets/tooltips/shapeitem.cpp deleted file mode 100644 index c66c7ab958f..00000000000 --- a/examples/widgets/widgets/tooltips/shapeitem.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "shapeitem.h" - -//! [0] -QPainterPath ShapeItem::path() const -{ - return myPath; -} -//! [0] - -//! [1] -QPoint ShapeItem::position() const -{ - return myPosition; -} -//! [1] - -//! [2] -QColor ShapeItem::color() const -{ - return myColor; -} -//! [2] - -//! [3] -QString ShapeItem::toolTip() const -{ - return myToolTip; -} -//! [3] - -//! [4] -void ShapeItem::setPath(const QPainterPath &path) -{ - myPath = path; -} -//! [4] - -//! [5] -void ShapeItem::setToolTip(const QString &toolTip) -{ - myToolTip = toolTip; -} -//! [5] - -//! [6] -void ShapeItem::setPosition(const QPoint &position) -{ - myPosition = position; -} -//! [6] - -//! [7] -void ShapeItem::setColor(const QColor &color) -{ - myColor = color; -} -//! [7] diff --git a/examples/widgets/widgets/tooltips/shapeitem.h b/examples/widgets/widgets/tooltips/shapeitem.h deleted file mode 100644 index 6c0643fa89e..00000000000 --- a/examples/widgets/widgets/tooltips/shapeitem.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef SHAPEITEM_H -#define SHAPEITEM_H - -#include -#include -#include - -//! [0] -class ShapeItem -{ -public: - void setPath(const QPainterPath &path); - void setToolTip(const QString &toolTip); - void setPosition(const QPoint &position); - void setColor(const QColor &color); - - QPainterPath path() const; - QPoint position() const; - QColor color() const; - QString toolTip() const; - -private: - QPainterPath myPath; - QPoint myPosition; - QColor myColor; - QString myToolTip; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp deleted file mode 100644 index ee588eea565..00000000000 --- a/examples/widgets/widgets/tooltips/sortingbox.cpp +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "sortingbox.h" - -#include -#include -#include -#include -#include -#include -#include - -//! [0] -SortingBox::SortingBox(QWidget *parent) - : QWidget(parent) -{ -//! [0] //! [1] - setMouseTracking(true); -//! [1] //! [2] - setBackgroundRole(QPalette::Base); -//! [2] - - itemInMotion = nullptr; - -//! [3] - newCircleButton = createToolButton(tr("New Circle"), - QIcon(":/images/circle.png"), - &SortingBox::createNewCircle); - - newSquareButton = createToolButton(tr("New Square"), - QIcon(":/images/square.png"), - &SortingBox::createNewSquare); - - newTriangleButton = createToolButton(tr("New Triangle"), - QIcon(":/images/triangle.png"), - &SortingBox::createNewTriangle); - - circlePath.addEllipse(QRect(0, 0, 100, 100)); - squarePath.addRect(QRect(0, 0, 100, 100)); - - qreal x = trianglePath.currentPosition().x(); - qreal y = trianglePath.currentPosition().y(); - trianglePath.moveTo(x + 120 / 2, y); - trianglePath.lineTo(0, 100); - trianglePath.lineTo(120, 100); - trianglePath.lineTo(x + 120 / 2, y); - -//! [3] //! [4] - setWindowTitle(tr("Tool Tips")); - resize(500, 300); - - createShapeItem(circlePath, tr("Circle"), initialItemPosition(circlePath), - initialItemColor()); - createShapeItem(squarePath, tr("Square"), initialItemPosition(squarePath), - initialItemColor()); - createShapeItem(trianglePath, tr("Triangle"), - initialItemPosition(trianglePath), initialItemColor()); -} -//! [4] - -//! [27] -SortingBox::~SortingBox() -{ - qDeleteAll(shapeItems); -} -//! [27] - -//! [5] -bool SortingBox::event(QEvent *event) -{ -//! [5] //! [6] - if (event->type() == QEvent::ToolTip) { - QHelpEvent *helpEvent = static_cast(event); - int index = itemAt(helpEvent->pos()); - if (index != -1) { - QToolTip::showText(helpEvent->globalPos(), shapeItems[index]->toolTip()); - } else { - QToolTip::hideText(); - event->ignore(); - } - - return true; - } - return QWidget::event(event); -} -//! [6] - -//! [7] -void SortingBox::resizeEvent(QResizeEvent * /* event */) -{ - int margin = style()->pixelMetric(QStyle::PM_LayoutTopMargin); - int x = width() - margin; - int y = height() - margin; - - y = updateButtonGeometry(newCircleButton, x, y); - y = updateButtonGeometry(newSquareButton, x, y); - updateButtonGeometry(newTriangleButton, x, y); -} -//! [7] - -//! [8] -void SortingBox::paintEvent(QPaintEvent * /* event */) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - for (const ShapeItem *shapeItem : std::as_const(shapeItems)) { -//! [8] //! [9] - painter.translate(shapeItem->position()); -//! [9] //! [10] - painter.setBrush(shapeItem->color()); - painter.drawPath(shapeItem->path()); - painter.translate(-shapeItem->position()); - } -} -//! [10] - -//! [11] -void SortingBox::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - int index = itemAt(event->position().toPoint()); - if (index != -1) { - itemInMotion = shapeItems[index]; - previousPosition = event->position().toPoint(); - shapeItems.move(index, shapeItems.size() - 1); - update(); - } - } -} -//! [11] - -//! [12] -void SortingBox::mouseMoveEvent(QMouseEvent *event) -{ - if ((event->buttons() & Qt::LeftButton) && itemInMotion) - moveItemTo(event->position().toPoint()); -} -//! [12] - -//! [13] -void SortingBox::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton && itemInMotion) { - moveItemTo(event->position().toPoint()); - itemInMotion = nullptr; - } -} -//! [13] - -//! [14] -void SortingBox::createNewCircle() -{ - static int count = 1; - createShapeItem(circlePath, tr("Circle <%1>").arg(++count), - randomItemPosition(), randomItemColor()); -} -//! [14] - -//! [15] -void SortingBox::createNewSquare() -{ - static int count = 1; - createShapeItem(squarePath, tr("Square <%1>").arg(++count), - randomItemPosition(), randomItemColor()); -} -//! [15] - -//! [16] -void SortingBox::createNewTriangle() -{ - static int count = 1; - createShapeItem(trianglePath, tr("Triangle <%1>").arg(++count), - randomItemPosition(), randomItemColor()); -} -//! [16] - -//! [17] -qsizetype SortingBox::itemAt(const QPoint &pos) -{ - for (qsizetype i = shapeItems.size() - 1; i >= 0; --i) { - const ShapeItem *item = shapeItems[i]; - if (item->path().contains(pos - item->position())) - return i; - } - return -1; -} -//! [17] - -//! [18] -void SortingBox::moveItemTo(const QPoint &pos) -{ - QPoint offset = pos - previousPosition; - itemInMotion->setPosition(itemInMotion->position() + offset); -//! [18] //! [19] - previousPosition = pos; - update(); -} -//! [19] - -//! [20] -int SortingBox::updateButtonGeometry(QToolButton *button, int x, int y) -{ - QSize size = button->sizeHint(); - button->setGeometry(x - size.rwidth(), y - size.rheight(), - size.rwidth(), size.rheight()); - - return y - size.rheight() - - style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing); -} -//! [20] - -//! [21] -void SortingBox::createShapeItem(const QPainterPath &path, - const QString &toolTip, const QPoint &pos, - const QColor &color) -{ - ShapeItem *shapeItem = new ShapeItem; - shapeItem->setPath(path); - shapeItem->setToolTip(toolTip); - shapeItem->setPosition(pos); - shapeItem->setColor(color); - shapeItems.append(shapeItem); - update(); -} -//! [21] - -//! [22] -template -QToolButton *SortingBox::createToolButton(const QString &toolTip, - const QIcon &icon, const PointerToMemberFunction &member) -{ - QToolButton *button = new QToolButton(this); - button->setToolTip(toolTip); - button->setIcon(icon); - button->setIconSize(QSize(32, 32)); - connect(button, &QToolButton::clicked, this, member); - - return button; -} -//! [22] - -//! [23] -QPoint SortingBox::initialItemPosition(const QPainterPath &path) -{ - int x; - int y = (height() - qRound(path.controlPointRect().height()) / 2); - if (shapeItems.size() == 0) - x = ((3 * width()) / 2 - qRound(path.controlPointRect().width())) / 2; - else - x = (width() / shapeItems.size() - - qRound(path.controlPointRect().width())) / 2; - - return QPoint(x, y); -} -//! [23] - -//! [24] -QPoint SortingBox::randomItemPosition() -{ - return QPoint(QRandomGenerator::global()->bounded(width() - 120), QRandomGenerator::global()->bounded(height() - 120)); -} -//! [24] - -//! [25] -QColor SortingBox::initialItemColor() -{ - return QColor::fromHsv(((shapeItems.size() + 1) * 85) % 256, 255, 190); -} -//! [25] - -//! [26] -QColor SortingBox::randomItemColor() -{ - return QColor::fromHsv(QRandomGenerator::global()->bounded(256), 255, 190); -} -//! [26] diff --git a/examples/widgets/widgets/tooltips/sortingbox.h b/examples/widgets/widgets/tooltips/sortingbox.h deleted file mode 100644 index 9f34cf7ada9..00000000000 --- a/examples/widgets/widgets/tooltips/sortingbox.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef SORTINGBOX_H -#define SORTINGBOX_H - -#include "shapeitem.h" - -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QPoint; -class QToolButton; -QT_END_NAMESPACE - -//! [0] -class SortingBox : public QWidget -{ - Q_OBJECT - -public: - SortingBox(QWidget *parent = nullptr); - ~SortingBox(); - -protected: - bool event(QEvent *event) override; - void resizeEvent(QResizeEvent *event) override; - void paintEvent(QPaintEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - -private slots: - void createNewCircle(); - void createNewSquare(); - void createNewTriangle(); -//! [0] - -//! [1] -private: - int updateButtonGeometry(QToolButton *button, int x, int y); - void createShapeItem(const QPainterPath &path, const QString &toolTip, - const QPoint &pos, const QColor &color); - qsizetype itemAt(const QPoint &pos); - void moveItemTo(const QPoint &pos); - QPoint initialItemPosition(const QPainterPath &path); - QPoint randomItemPosition(); - QColor initialItemColor(); - QColor randomItemColor(); - template - QToolButton *createToolButton(const QString &toolTip, const QIcon &icon, -//! [1] - const PointerToMemberFunction &member); - -//! [2] - QList shapeItems; - QPainterPath circlePath; - QPainterPath squarePath; - QPainterPath trianglePath; - - QPoint previousPosition; - ShapeItem *itemInMotion; - - QToolButton *newCircleButton; - QToolButton *newSquareButton; - QToolButton *newTriangleButton; -}; -//! [2] - -#endif diff --git a/examples/widgets/widgets/tooltips/tooltips.pro b/examples/widgets/widgets/tooltips/tooltips.pro deleted file mode 100644 index d14b8295ba1..00000000000 --- a/examples/widgets/widgets/tooltips/tooltips.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets - -HEADERS = shapeitem.h \ - sortingbox.h -SOURCES = main.cpp \ - shapeitem.cpp \ - sortingbox.cpp -RESOURCES = tooltips.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/tooltips -INSTALLS += target diff --git a/examples/widgets/widgets/tooltips/tooltips.qrc b/examples/widgets/widgets/tooltips/tooltips.qrc deleted file mode 100644 index dabc894e9bf..00000000000 --- a/examples/widgets/widgets/tooltips/tooltips.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/circle.png - images/square.png - images/triangle.png - - diff --git a/examples/widgets/widgets/widgets.pro b/examples/widgets/widgets/widgets.pro index 7384b69743c..9fe06d4d808 100644 --- a/examples/widgets/widgets/widgets.pro +++ b/examples/widgets/widgets/widgets.pro @@ -9,5 +9,4 @@ SUBDIRS = analogclock \ sliders \ spinboxes \ tablet \ - tooltips \ windowflags diff --git a/src/widgets/doc/snippets/tooltips/main.cpp b/src/widgets/doc/snippets/tooltips/main.cpp new file mode 100644 index 00000000000..94cc71f7118 --- /dev/null +++ b/src/widgets/doc/snippets/tooltips/main.cpp @@ -0,0 +1,74 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include + +using SearchBar = QWidget; +using Element = QWidget; + +class Window : public QMainWindow +{ +public: + Window(QWidget *parent = nullptr); + +protected: + bool event(QEvent *event) override; + +private: + Element *elementAt(QPoint pos) const { + return nullptr; + } + + QToolBar *fileToolBar; + QMenu *fileMenu; + + SearchBar *searchBar; +}; + + +Window::Window(QWidget *parent) + : QMainWindow(parent) +{ +//! [action_tooltip] + QAction *openAction = new QAction(tr("&Open...")); + openAction->setToolTip(tr("Open an existing file")); + + fileMenu = menuBar()->addMenu(tr("&File")); + fileToolBar = addToolBar(tr("&File")); + + fileMenu->addAction(openAction); + fileToolBar->addAction(openAction); +//! [action_tooltip] + +//! [static_tooltip] + searchBar = new SearchBar; + searchBar->setToolTip(tr("Search in the current document")); +//! [static_tooltip] + + fileToolBar->addWidget(searchBar); +} + +//! [dynamic_tooltip] +bool Window::event(QEvent *event) +{ + if (event->type() == QEvent::ToolTip) { + QHelpEvent *helpEvent = static_cast(event); + if (Element *element = elementAt(helpEvent->pos())) { + QToolTip::showText(helpEvent->globalPos(), element->toolTip()); + } else { + QToolTip::hideText(); + event->ignore(); + } + + return true; + } + return QWidget::event(event); +} +//! [dynamic_tooltip] + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Window w; + return 0; +} diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 2c68b029b01..2800f65ac62 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -45,15 +45,24 @@ using namespace Qt::StringLiterals; Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with \c{

}. - The simplest and most common way to set a widget's tool tip is by - calling its QWidget::setToolTip() function. + UI elements that are created via \l{QAction} use the tooltip property + of the QAction, so for most interactive UI elements, setting that + property is the easiest way to provide tool tips. + + \snippet tooltips/main.cpp action_tooltip + + For any other widgets, the simplest and most common way to set + a widget's tool tip is by calling its QWidget::setToolTip() function. + + \snippet tooltips/main.cpp static_tooltip It is also possible to show different tool tips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget's \l {QWidget::}{event()} function and call QToolTip::showText() with - the text you want to display. The \l{widgets/tooltips}{Tooltips} - example illustrates this technique. + the text you want to display. + + \snippet tooltips/main.cpp dynamic_tooltip If you are calling QToolTip::hideText(), or QToolTip::showText() with an empty string, as a result of a \l{QEvent::}{ToolTip}-event you @@ -75,7 +84,7 @@ using namespace Qt::StringLiterals; \note Tool tips use the inactive color group of QPalette, because tool tips are not active windows. - \sa QWidget::toolTip, QAction::toolTip, {Tool Tips Example} + \sa QWidget::toolTip, QAction::toolTip */ class QTipLabel : public QLabel