main.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the example classes of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://trolltech.com/products/qt/licenses/licensing/opensource/
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
00017 ** or contact the sales department at sales@trolltech.com.
00018 **
00019 ** In addition, as a special exception, Trolltech gives you certain
00020 ** additional rights. These rights are described in the Trolltech GPL
00021 ** Exception version 1.0, which can be found at
00022 ** http://www.trolltech.com/products/qt/gplexception/ and in the file
00023 ** GPL_EXCEPTION.txt in this package.
00024 **
00025 ** In addition, as a special exception, Trolltech, as the sole copyright
00026 ** holder for Qt Designer, grants users of the Qt/Eclipse Integration
00027 ** plug-in the right for the Qt/Eclipse Integration to link to
00028 ** functionality provided by Qt Designer and its related libraries.
00029 **
00030 ** Trolltech reserves all rights not expressly granted herein.
00031 **
00032 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00033 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00034 **
00035 ****************************************************************************/
00036 
00037 #include "mouse.h"
00038 
00039 #include <QtGui>
00040 
00041 #include <math.h>
00042 
00043 static const int MouseCount = 7;
00044 
00045 int main(int argc, char **argv)
00046 {
00047     QApplication app(argc, argv);
00048     qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
00049 
00050     QGraphicsScene scene;
00051     scene.setSceneRect(-300, -300, 600, 600);
00052     scene.setItemIndexMethod(QGraphicsScene::NoIndex);
00053 
00054     for (int i = 0; i < MouseCount; ++i) {
00055         Mouse *mouse = new Mouse;
00056         mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
00057                       ::cos((i * 6.28) / MouseCount) * 200);
00058         scene.addItem(mouse);
00059     }
00060 
00061     QGraphicsView view(&scene);
00062     view.setRenderHint(QPainter::Antialiasing);
00063     view.setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
00064     view.setCacheMode(QGraphicsView::CacheBackground);
00065     view.setDragMode(QGraphicsView::ScrollHandDrag);
00066     view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
00067     view.resize(400, 300);
00068     view.show();
00069 
00070     return app.exec();
00071 }


csm
Author(s): Andrea Censi
autogenerated on Mon Jan 16 2017 03:48:29