O'Reilly logo

Qt 5 Blueprints by Symeon Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling the camera

The QCameraFocus class is mentioned to control the zoom and focus of the camera. Speaking of zoom, Qt supports both optical and digital zoom. As we all know, optical zoom offers a better quality than digital. Hence, optical zoom should take priority over digital.

Drag a horizontal slider and a label to MainWindow pane's verticalLayout just above the capture button. Name them zoomSlider and zoomLabel, respectively. Remember to change the text of zoomLabel to Zoom and Horizontal in alignment to AlignHCenter. Since Qt doesn't provide a floating point number slider, we simply multiply 10 to get an integer in the slider. Hence, change the minimum value of zoomSlider to 10, which means zoom by 1.0.

Include QCameraFocus in mainwindow.h ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required