No Description

mainwindow.cpp 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /// \fn MainWindow::MainWindow(QWidget *parent)
  7. /// \~English
  8. /// \brief Constructor
  9. /// \~Spanish
  10. /// \brief Constructor
  11. MainWindow::MainWindow(QWidget *parent) :
  12. QMainWindow(parent),
  13. ui(new Ui::MainWindow)
  14. {
  15. ui->setupUi(this);
  16. resize(1000,1000);
  17. scene = new QGraphicsScene(this) ;
  18. ui->mainView->resize(width()*.95,height()*.95);
  19. scene->setSceneRect(QRectF(QPoint(0,0), QPoint(width()*.95,height()*.95))) ;
  20. ui->mainView->setScene(scene) ;
  21. ui->mainView->setAlignment((Qt::AlignLeft | Qt::AlignTop));
  22. }
  23. /// \fn MainWindow::~MainWindow(QWidget *parent)
  24. /// \~English
  25. /// \brief Destructor
  26. /// \~Spanish
  27. /// \brief Destructor
  28. MainWindow::~MainWindow()
  29. {
  30. delete ui;
  31. delete scene;
  32. }
  33. /// \fn void MainWindow::addBird(int x, int y, Bird &b)
  34. /// \~English
  35. /// \brief Paints a bird into the MainWindow
  36. /// \param x X coordinate of the Main Window
  37. /// \param y Y coordinate of the Main Window
  38. /// \param b Bird object to be painted
  39. /// \~Spanish
  40. /// \brief Pinta un pajaro en la pantalla principal
  41. /// \param x Coordenada X de la pantalla principal
  42. /// \param y Coordenada Y de la pantalla principal
  43. /// \param b Objecto Bird a ser pintado
  44. void MainWindow::addBird(int x, int y, Bird &b){
  45. scene->addWidget(&b) ;
  46. b.move(x,y) ;
  47. }
  48. /// \fn void MainWindow::addBird(Bird &b)
  49. /// \~English
  50. /// \brief Paints a bird into the MainWindow
  51. /// \param b Bird object to be painted
  52. /// \~Spanish
  53. /// \brief Pinta un pajaro en la pantalla principal
  54. /// \param b Objecto Bird a ser pintado
  55. void MainWindow::addBird(Bird &b){
  56. scene->addWidget(&b) ;
  57. }