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 ,
{
....
DrawMatrix();
..
}
void aWidget::DrawMatrix()
{
squares.setRect(1000,1000,50,50);
//squares = new QGraphicsRectItem();
//squares = matrixScene.addRect(QRectF(10,50,100,100));
matrixScene->addItem(&squares);
matrixView->setScene(matrixScene);
}
#include <QtGui>
#include <QWidget>
#include "ui_ninesilicawidget.h"
{
Q_OBJECT
...
Ui::NineSilicaWidgetClass ui;
..
...
};
#endif // NINESILICAWIDGET_H
aWidget::aWidget(QWidget *parent)
: QWidget(parent)
{
....
matrixScene = new QGraphicsScene();
matrixView = new QGraphicsView(matrixScene);
DrawMatrix();
..
}
void aWidget::DrawMatrix()
{
squares.setRect(1000,1000,50,50);
//squares = new QGraphicsRectItem();
//squares = matrixScene.addRect(QRectF(10,50,100,100));
matrixScene->addItem(&squares);
matrixView->setScene(matrixScene);
}
#include <QtGui>
#include <QWidget>
#include "ui_ninesilicawidget.h"
class aWidget : public QWidget
{
Q_OBJECT
...
QGraphicsView *matrixView;
QGraphicsScene *matrixScene;
QGraphicsRectItem squares;
Ui::NineSilicaWidgetClass ui;
..
...
};
#endif // NINESILICAWIDGET_H
To copy to clipboard, switch view to plain text mode
Bookmarks