Hi,
Trying to understand the basics of Graphics View,
I have written a simple code snippet to do so,
int main(int argc, char *argv[])
{
qDebug("In Main");
viewGv->setScene(scene);
scene
->setSceneRect
(QRectF(0,
0 ,
10,
10));
scene->setBackgroundBrush(Qt::blue);
pen1.setColor(Qt::red);
scene->addLine(0,0, 10,10, pen1);
viewGv->show();
return a.exec();
}
int main(int argc, char *argv[])
{
qDebug("In Main");
QApplication a(argc, argv);
QGraphicsScene *scene = new QGraphicsScene();
QGraphicsView *viewGv = new QGraphicsView();
viewGv->setScene(scene);
scene->setSceneRect(QRectF(0, 0 , 10, 10));
QGraphicsTextItem * item1 = scene->addText("Hello World");
scene->setBackgroundBrush(Qt::blue);
QPen pen1;
pen1.setColor(Qt::red);
scene->addLine(0,0, 10,10, pen1);
viewGv->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Here i have set the scene rect as (0,0,10,10), and have set its background to blue color.
When i run the application a small window appears as intended when i maximise it the entire window is filled with blue color....
I expected only the area (0,0,10,10) which represents the scene to be filled as blue..
whats happening here can anyone help me understand this???
Bookmarks