Image scaling and cropping

Since we learned about the File Selection Dialog in the previous section, I'd thought we should learn something fun this time!

First off, let's create a new Qt Widgets Application. Then, open up mainwindow.ui and create the following user interface:

Let's dissect this user interface into three parts:

  • Top—Image preview:
    • First, add a Horizontal Layout to the window.
    • Then, add a Label widget into the Horizontal Layout we just added, then set the text property to empty. Set both the label's minimumSize and maximumSize properties to 150x150. Finally, set the frameShape property under the QFrame category to Box.
    • Add ...

Get Hands-On GUI Programming with C++ and Qt5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.