Main Page
Modules
Namespaces
Classes
Files
File List
File Members
sm
apps
qtv
main.cpp
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
4
**
5
** This file is part of the example classes of the Qt Toolkit.
6
**
7
** This file may be used under the terms of the GNU General Public
8
** License version 2.0 as published by the Free Software Foundation
9
** and appearing in the file LICENSE.GPL included in the packaging of
10
** this file. Please review the following information to ensure GNU
11
** General Public Licensing requirements will be met:
12
** http://trolltech.com/products/qt/licenses/licensing/opensource/
13
**
14
** If you are unsure which license is appropriate for your use, please
15
** review the following information:
16
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
17
** or contact the sales department at sales@trolltech.com.
18
**
19
** In addition, as a special exception, Trolltech gives you certain
20
** additional rights. These rights are described in the Trolltech GPL
21
** Exception version 1.0, which can be found at
22
** http://www.trolltech.com/products/qt/gplexception/ and in the file
23
** GPL_EXCEPTION.txt in this package.
24
**
25
** In addition, as a special exception, Trolltech, as the sole copyright
26
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
27
** plug-in the right for the Qt/Eclipse Integration to link to
28
** functionality provided by Qt Designer and its related libraries.
29
**
30
** Trolltech reserves all rights not expressly granted herein.
31
**
32
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
33
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
34
**
35
****************************************************************************/
36
37
#include "
mouse.h
"
38
39
#include <QtGui>
40
41
#include <math.h>
42
43
static
const
int
MouseCount
= 7;
44
45
int
main
(
int
argc,
char
**argv)
46
{
47
QApplication app(argc, argv);
48
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
49
50
QGraphicsScene scene;
51
scene.setSceneRect(-300, -300, 600, 600);
52
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
53
54
for
(
int
i = 0; i <
MouseCount
; ++i) {
55
Mouse
*mouse =
new
Mouse
;
56
mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
57
::cos((i * 6.28) / MouseCount) * 200);
58
scene.addItem(mouse);
59
}
60
61
QGraphicsView view(&scene);
62
view.setRenderHint(QPainter::Antialiasing);
63
view.setBackgroundBrush(QPixmap(
":/images/cheese.jpg"
));
64
view.setCacheMode(QGraphicsView::CacheBackground);
65
view.setDragMode(QGraphicsView::ScrollHandDrag);
66
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView,
"Colliding Mice"
));
67
view.resize(400, 300);
68
view.show();
69
70
return
app.exec();
71
}
main
int main(int argc, char **argv)
Definition:
main.cpp:45
mouse.h
Mouse
Definition:
mouse.h:43
MouseCount
static const int MouseCount
Definition:
main.cpp:43
csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23