i have a very basic problem ,i am trying to draw a rectangle in my widget at a certain position but it wont draw ,below is the code ,
Qt Code:
  1. aWidget::aWidget(QWidget *parent)
  2. : QWidget(parent)
  3. {
  4.  
  5. ....
  6. matrixScene = new QGraphicsScene();
  7. matrixView = new QGraphicsView(matrixScene);
  8. DrawMatrix();
  9. ..
  10. }
  11. void aWidget::DrawMatrix()
  12. {
  13. squares.setRect(1000,1000,50,50);
  14. //squares = new QGraphicsRectItem();
  15. //squares = matrixScene.addRect(QRectF(10,50,100,100));
  16. matrixScene->addItem(&squares);
  17. matrixView->setScene(matrixScene);
  18. }
  19. #include <QtGui>
  20. #include <QWidget>
  21. #include "ui_ninesilicawidget.h"
  22.  
  23. class aWidget : public QWidget
  24. {
  25. Q_OBJECT
  26. ...
  27. QGraphicsView *matrixView;
  28. QGraphicsScene *matrixScene;
  29. Ui::NineSilicaWidgetClass ui;
  30. ..
  31. ...
  32. };
  33.  
  34. #endif // NINESILICAWIDGET_H
To copy to clipboard, switch view to plain text mode