설명 없음

mainwindow.cpp 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // RAN [2014-06-03]
  2. // - Set initial size of the window to 1000,1000. Adjust the
  3. // mainView and scene accordingly.
  4. #include "mainwindow.h"
  5. #include "ui_mainwindow.h"
  6. #include <QTime>
  7. #include <QTimer>
  8. #include <QDebug>
  9. #include <ctime>
  10. /// \fn MainWindow::MainWindow(QWidget *parent)
  11. /// \~English
  12. /// \brief Constructor
  13. /// \~Spanish
  14. /// \brief Constructor
  15. MainWindow::MainWindow(QWidget *parent) :
  16. QMainWindow(parent),
  17. ui(new Ui::MainWindow)
  18. {
  19. ui->setupUi(this);
  20. resize(1000,1000);
  21. scene = new QGraphicsScene(this) ;
  22. ui->mainView->resize(width()*.95,height()*.95);
  23. scene->setSceneRect(QRectF(QPoint(0,0), QPoint(width()*.95,height()*.95))) ;
  24. ui->mainView->setScene(scene) ;
  25. ui->mainView->setAlignment((Qt::AlignLeft | Qt::AlignTop));
  26. QTime now = QTime::currentTime();
  27. qsrand(now.msec());
  28. srand(time(NULL)) ;
  29. }
  30. /// \fn MainWindow::~MainWindow(QWidget *parent)
  31. /// \~English
  32. /// \brief Destructor
  33. /// \~Spanish
  34. /// \brief Destructor
  35. MainWindow::~MainWindow()
  36. {
  37. delete ui;
  38. delete scene;
  39. }
  40. /// \fn void MainWindow::addBird(int x, int y, Bird &b)
  41. /// \~English
  42. /// \brief Paints a bird into the MainWindow
  43. /// \param x X coordinate of the Main Window
  44. /// \param y Y coordinate of the Main Window
  45. /// \param b Bird object to be painted
  46. /// \~Spanish
  47. /// \brief Pinta un pajaro en la pantalla principal
  48. /// \param x Coordenada X de la pantalla principal
  49. /// \param y Coordenada Y de la pantalla principal
  50. /// \param b Objecto Bird a ser pintado
  51. void MainWindow::addBird(int x, int y, Bird &b){
  52. scene->addWidget(&b) ;
  53. b.move(x,y) ;
  54. }
  55. /// \fn void MainWindow::addBird(Bird &b)
  56. /// \~English
  57. /// \brief Paints a bird into the MainWindow
  58. /// \param b Bird object to be painted
  59. /// \~Spanish
  60. /// \brief Pinta un pajaro en la pantalla principal
  61. /// \param b Objecto Bird a ser pintado
  62. void MainWindow::addBird(Bird &b){
  63. scene->addWidget(&b) ;
  64. }