[Qt-interest] QGraphicView and QScene
Sergio
hardmaker at gmail.com
Tue Aug 23 00:17:23 CEST 2011
Hi list. I'm new in Qt and I'm trying to make a little application to
draw a math function (to learn about qt) and I was found a problem.
Googling I can't find the solution.
The problem is:
I make a litlle dialog in QtCreator 4.7 with a QGraphicView and a
button. When press button, execute this code:
//QGraphicsLineItem *unaLinea = new QGraphicsLineItem(0,0,30,30);
QGraphicsScene *scene = new QGraphicsScene(-200,-200, 400, 400);
//scene->addLine(1,1,30,30);
scene->addLine(0, 0, 20, 20);
scene->addLine(scene->sceneRect().left(),0,scene->sceneRect().right(),0);
scene->addLine(0,scene->sceneRect().top(),0,scene->sceneRect().bottom());
ui->graphicsView->setScene(scene);
ui->graphicsView->setSceneRect(QRect(-200,-200, 400, 400));
ui->graphicsView->show();
The graphicview show the line and add a vertical scrollbar. But when
maximize the dialog, the the lines are in the center of the
graphicsView.
How can I do to rezise the original Rect of the scente to all
qgraphicview, to use all space and update the draw to new space.
More specifically, how can draw a scene in all graphicview updating
the picture when the graphicview change size.
Thank's a lot.
Sergio
More information about the Qt-interest-old
mailing list