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 Layoutto the window. - Then, add a
Labelwidget into theHorizontal Layoutwe just added, then set thetextproperty toempty. Set both the label'sminimumSizeandmaximumSizeproperties to 150x150. Finally, set theframeShapeproperty under theQFramecategory toBox. - Add two
Horizontal Spacersto the sides of the label to make it centered.
- First, add a
- Middle—Sliders for adjustments:
- Add a
Form Layoutto the window, below theHorizontal Layoutwe just added previously in step 1. - Add three
Labelsto theForm Layout, and set theirtextproperty toScale:,Horizontal:, andVertical:respectively. - Add three
Horizontal Slidersto theForm Layout. Set...
- Add a