Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]Can't show the image with default size after calling fitInView



  • Every time I load the pixmap, I will call

    @
    graph_pixmap_->setPixmap(QPixmap::fromImage(image));
    graph_scene_->setSceneRect(image.rect());
    @

    After I fit the pixmap into the view

    @
    graph_pixmap_->setPixmap(QPixmap::fromImage(image));
    graph_view_->fitInView(graph_pixmap_, Qt::KeepAspectRatio);
    @

    Then whatever every images I open wouldn't show the image with
    the original size of the image again.

    How could I ask the graph_view_ show the images by the original size again?



  • I solved the problem
    @
    graph_pixmap_->setPixmap(QPixmap::fromImage(image));
    graph_scene_->setSceneRect(image.rect());
    graph_view_->resetMatrix(); //call this
    @

    because fitInView would change the matrix, so I should reset it every time I open
    the image, thanks


Log in to reply