July 17, 2010

ferrazrafael ferrazrafael
Lab Rat
13 posts

Difficulty to show only what I want in QGraphicsview

 

Hello every one.

Im using Qtcreator 2.0, and Im having difficulty to show only what I placed in the Scene.
My code is like that:

  1. ui->graphicsView->setScene(new QGraphicsScene());
  2. QPolygon Polygon;
  3. Polygon.append(QPoint(1,1));
  4. Polygon.append(QPoint(1,2));
  5. Polygon.append(QPoint(2,2));
  6. Polygon.append(QPoint(2,1));
  7. ui->graphicsView->scene()->addPolygon(Polygon);
  8. ui->graphicsView->fitInView(ui->graphicsView->items().at(0),Qt::KeepAspectRatio);

The Polygone that Im inserting is showed better when it run the last command. but it still small in the QGraphicsview

Anyone knows how to solve this?

1 reply

July 30, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

Hi,

  1. ui->graphicsView->fitInView(ui->graphicsView->items().at(0),Qt::KeepAspectRatio);

instead of that, I think you can directly use view->setTransform() or view->scale()

 
  ‹‹ Using Qt signals and slots with multiple inheritance      QFtp example, problem with download ››

You must log in to post a reply. Not a member yet? Register here!