Important: Please read the Qt Code of Conduct -

QCamera - Window size not same as aspect ratio SOLVED

  • I am working on a windows desktop application that normally displays input from a camera on half the screen. But I will have the ability to bring the camera display up to fill the window. I am just learning Qt and Qt Creator so progress has been slow. But at least there has been progress.

    With the window split in half the size of the widget containing the camera output does not match the aspect ratio of the camera. At this point it is stretching the image. The first thought was to force the displayed image to match the proper aspect ration of the camera. However I don't want it to have letter boxing. And I will probably have the same problem when I switch to fill the window. So how do I establish a view from the camera that I can fill whatever the size of the window is without stretching. I'd much rather cut off the sides or top and bottom instead of stretching or having it letter box.

    I am using QCamera and QCameraViewfinder. If necessary I can provide code.

  • I finally rewrote the code to use QGraphicsView and QGraphicsScene. I used QGraphicsPixmapItem for the image. In order to properly center the image I used the setPos function of QGraphicsItem with a negative x and/or y to get the area of the image that I wanted to be visible.

Log in to reply