Time for action – Loading an example project
Examples are a great way to explore the capabilities of Qt and find the code required for some typical tasks. Each Qt version contains a large set of examples that are always up to date. Qt Creator provides an easy way to load and compile any example project.
Let's try loading one to get familiar with Qt Creator's project editing interface. Then, we will build the project to check whether the installation and configuration were done correctly.
In Qt Creator, click on the Welcome button in the top-left corner of the window to switch to the Welcome mode. Click on the Examples button (refer to the previous screenshot) to open the list of examples with a search box. Ensure that the kit that you want to use is chosen in the drop-down list next to the search box. In the box, enter aff to filter the list of examples and click on Affine Transformations to open the project. If you are asked whether you want to copy the project to a new folder, agree.
After selecting an example, an additional window appears that contains the documentation page of the loaded example. You can close that window when you don't need it. Switch back to the main Qt Creator window.
Qt Creator will display the Configure Project dialog with the list of available kits:
Verify that the kits you want to use are marked with check boxes, and click on the Configure Project button. Qt Creator will then present you with the following window:
This is the Edit mode of Qt Creator. Let's go through the most important parts of this interface:
- Project tree is located at the top-left of the window. It displays all open projects and the hierarchy of files within them. You can double-click on a file to open it for editing. The context menu of projects, directories, and files in the project tree contains a lot of useful functions.
- At the bottom-left of the window, there's a list of open documents. The file selected in this list will appear in the code editor in the center of the window. If the selected file is a Qt Designer form, Qt Creator will automatically switch to the Design mode. Each file in the list has a close button.
- The Type to locate field is present at the left of the bottom panel. If you want to quickly navigate to another file in the project, type the beginning of its name in the field and select it in the pop-up list. Special prefixes can be used to enable other search modes. For example, the c prefix allows you to search for C++ classes. You can press Ctrl + K to activate this field.
- The buttons at the bottom of the left panel allow you to build and run your current project under debugger, or normally. The button above them displays names of the current project and the current build configuration (for example, Debug or Release) and allows you to change them.
- The output panes appear below the code editor when you select them in the bottom panel. The Issues pane contains compiler errors and other related messages. The Search Results pane allows you to run a text search in the entire project and view its results. The Application Output pane displays the text your application has printed to its standard output (stderr or stdout).