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 theHorizontal Layout
we just added, then set thetext
property toempty
. Set both the label'sminimumSize
andmaximumSize
properties to 150x150. Finally, set theframeShape
property under theQFrame
category toBox
. - Add two
Horizontal Spacers
to the sides of the label to make it centered.
- First, add a
- Middle—Sliders for adjustments:
- Add a
Form Layout
to the window, below theHorizontal Layout
we just added previously in step 1. - Add three
Labels
to theForm Layout
, and set theirtext
property toScale:
,Horizontal:
, andVertical:
respectively. - Add three
Horizontal Sliders
to theForm Layout
. Set...
- Add a