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:

    @
    ui->graphicsView->setScene(new QGraphicsScene());
    QPolygon Polygon;
    Polygon.append(QPoint(1,1));
    Polygon.append(QPoint(1,2));
    Polygon.append(QPoint(2,2));
    Polygon.append(QPoint(2,1));
    ui->graphicsView->scene()->addPolygon(Polygon);
    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?



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

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.