Debian Codegraph @

tests/manual/examples/widgets/touch/pinchzoom/main.cpp

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4 #include "graphicsview.h"
5 #include "mouse.h"
6
7 #include <QApplication>
8 #include <cmath>
9
10 static constexpr int MouseCount = 7;
11
12 //! [0]
13 int main(int argc, char **argv)
14 {
15 QApplication app(argc, argv);
16 //! [0]
17
18 //! [1]
19 QGraphicsScene scene;
20 scene.setSceneRect(-300, -300, 600, 600);
21 //! [1] //! [2]
22 scene.setItemIndexMethod(QGraphicsScene::NoIndex);
23 //! [2]
24
25 //! [3]
26 for (int i = 0; i < MouseCount; ++i) {
27 Mouse *mouse = new Mouse;
28 mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
29 ::cos((i * 6.28) / MouseCount) * 200);
30 scene.addItem(mouse);
31 }
32 //! [3]
33
34 //! [4]
35 GraphicsView view(&scene);
36 view.setRenderHint(QPainter::Antialiasing);
37 view.setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
38 //! [4] //! [5]
39 view.setCacheMode(QGraphicsView::CacheBackground);
40 view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
41 //! [5] //! [6]
42 view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
43 view.showMaximized();
44
45 return app.exec();
46 }
47 //! [6]