[Qt-interest] micecollider example not showing up in a Qt Desinger's generated Graphics View widget
Usman Ajmal
uzmanajmal at gmail.com
Thu Jul 9 06:50:46 CEST 2009
Hi,
I am trying to run the micecollider example (given in tutorial of tolltech)
in a Window generated with the help of Qt Designer. In that window i have a
Graphics View in which i am intending to show the mice running here and
there.
I have added the mouse.cpp/h file to my project directory and add the code
in micecollider's main.cpp file to my Ui_MainWindow. When i run i get no
errors but the mice program do not get loaded in my Graphics View. Following
is the snippet of code of setupUi(QMainWindow *MainWindow) that is creating
problem, i guess. Please let me know what should i do?
I added the code of main.cpp of micecollider to Ui_MainWindow class because
i had to use the graphicsView pointer created by Qt Designer.
Here goes the code
void setupUi(QMainWindow *MainWindow)
QGraphicsView *graphicsView;
....
....
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
QGraphicsScene scene;
// scene.setSceneRect(-300, -300, 600, 600);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
for (int i = 0; i < MouseCount; ++i) {
Mouse *mouse = new Mouse;
mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
::cos((i * 6.28) / MouseCount) * 200);
scene.addItem(mouse);
}
graphicsView = new QGraphicsView(&scene, tab); //my graphicsView is in
a tab named 'tab'
graphicsView->setRenderHint(QPainter::Antialiasing);
graphicsView->setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
graphicsView->setCacheMode(QGraphicsView::CacheBackground);
graphicsView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
graphicsView->setGeometry(QRect(10, 10, 721, 541));
graphicsView->show();
Full ui_MainWindow.h code is here http://pastebin.com/m4d7220b
Thanks for helping always
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090709/0f0da4bf/attachment.html
More information about the Qt-interest-old
mailing list