• I just started learning how to display images to the User. In reading through the documentation it seems that the QGraphicsView and QGraphicsScene offer the best approach. Basically, I want to a display a map to the User in the main Window and then overlay dialog boxes containing controls and/or other information to the user.

    In my first attempt to display the base image to the User it was displayed in repeating panels. I just want to display a single image centered on the screen. I've been reading through the documentation but so far haven't discovered how to center the image in the view.

    QGraphicsScene scene;
    scene.setSceneRect(-300, -300, 600, 600);

    QGraphicsView view(&scene);
    view.setContentsMargins(QMargins::QMargins(5, 5, 5, 5));
    view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Map Test"));
    view.resize(900, 700);


  • If you want a single image, AFAIK, you'll need to use QGraphicsItem (or QGraphicsWidget). Setting the image as a background brush will, as you've observed, result in it being tiled, because it is painted across the entirety of the background.

Log in to reply

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