summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/tooltips/sortingbox.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-23 18:09:47 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-27 07:55:34 +0200
commitae39b1634556f82fe5d7505ed9b6ebb883d6f813 (patch)
treef67c5bfc126e8b3f9204391938209fb5b565f3e6 /examples/widgets/widgets/tooltips/sortingbox.h
parent70df82a919a584a8e691d9aef633fe7a2e3e0d30 (diff)
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. Pick-to: 6.6 Change-Id: I7874c66765c5b46230c92846ee3de1ee83f47e45 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'examples/widgets/widgets/tooltips/sortingbox.h')
-rw-r--r--examples/widgets/widgets/tooltips/sortingbox.h71
1 files changed, 0 insertions, 71 deletions
diff --git a/examples/widgets/widgets/tooltips/sortingbox.h b/examples/widgets/widgets/tooltips/sortingbox.h
deleted file mode 100644
index 9f34cf7ada..0000000000
--- 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 <QWidget>
-
-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<typename PointerToMemberFunction>
- QToolButton *createToolButton(const QString &toolTip, const QIcon &icon,
-//! [1]
- const PointerToMemberFunction &member);
-
-//! [2]
- QList<ShapeItem *> shapeItems;
- QPainterPath circlePath;
- QPainterPath squarePath;
- QPainterPath trianglePath;
-
- QPoint previousPosition;
- ShapeItem *itemInMotion;
-
- QToolButton *newCircleButton;
- QToolButton *newSquareButton;
- QToolButton *newTriangleButton;
-};
-//! [2]
-
-#endif