C++ in Qt6 - Off-centered QPixmap while simulating video playback

64 views Asked by At

Background

I'm attempting to implement a platform-agnostic, timer-dependent "slide show" application in C++ for Qt v6.6. Currently, QPixmap instances are generated from raster files read into memory at the time the user selects an image source directory. Those resultant QPixmaps are stored in a member QList. A QGraphicsView instance — laid out with Qt Designer — is the rendering canvas.

The raster files read from the user-selected source directory are rendered to screen (more specifically, the solitary QGraphicsView widget) in the order of their names on the OS file system. The frame rate is set by a member QTimer instance with a hard-coded inter-frame delay.

Problem Description

After loading images that fill the viewing region, the next time non-filling images are rendered, they're top-left justified. If the non-filling images are rendered first on a fresh launch of the program, the images are centered in the QGraphicsView. The QPixmaps need to always be rendered in the center.

Example Code

Executable project repo: https://github.com/DaManDOH/PixmapPlayback

Question

What is the conventional way of centering (or more precisely, re-centering) QPixmaps in a QGraphicsView?

0

There are 0 answers