[SOLVED]Display small image to cover all available space.

  • I have a small, usually 8x8 image that I want to fit to my QGraphicsView.
    No matter how I resize my view the image should keep up and resize accordingly, so if for example I make my window fullscreen what I will see are 64 huge pixels.

    How can this be done?

    Side note: I know about fitInView but it seems that I can not use it correctly.

  • After experimenting for a while

    view->fitInView(view->scene()->sceneRect(), Qt::KeepAspectRatio);

    does what I want.
    Using also view->setAlignment(Qt::AlignTop);
    creates the effect quite nicely

Log in to reply

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