Below are our suggested configuration settings for Qt Creator. You are not required to adopt these settings, but we recommend them for a more pleasant experience.
Access the settings for Qt Creator from the top menu bar:
- on Windows or Linux, menu item is Tools -> Options…
- on Mac, menu item is Qt Creator -> Preferences…
Build & Run settings
We recommend checking the following boxes:
-
Save all files before build
This saves your code files before you compile or run your project.
-
Compile Output: Open pane when building
Display information about the compilation process when your project is being built.
-
Application Output: Open pane on output when running always
Display your program's output in a pane at the bottom of window. Normally you can see the output in the popup graphical console and don't need this bottom pane, but if your window crashes, the bottom output can be helpful to figure out what went wrong. Note: In newer versions of Qt this option is presented as a dropdown menu instead of a checkbox.
-
Application Output: Clear old output on a new run
This clears out previous output from the output pane.
Debugger settings
-
Debugger font size follows main editor
This will make your debugger font size grow if the main text editor font size is enlarged.
-
Switch to previous mode on debugger exit
This closes unneeded debugger panes when the debugger is no longer running.
Analyzer settings
Qt Creator has a feature called the "Clang Code Model" that highlights errors and gives code warnings as you type. Neat! However, the feature is a bit too picky, and it spits out a lot of warnings about code that is just fine. To make the feature a bit less picky, we'll change its default flags and settings to more closely match the CS 106B style guide.
In Qt Creator's preferences, go to the Analyzer area, then in the initial Clang Tools tab, find the area labeled "Default Clang-Tidy and Clazy checks" and click on it. Now a "Diagnostic Configurations" window will pop up with several entries in it. Click "Copy…" This will pop up a small window asking for your configuration's name. Name your new configuration something like "CS 106B settings" and press Enter. You should now see your configuration in the Diagnostic Configurations list. Make sure it is selected.
Now, below, under the "Clang Warnings" tab, replace the existing text with this text:
-Wall -Wextra -Wno-unused-parameter -Wmissing-field-initializers -Wno-old-style-cast
-Wno-sign-compare -Wno-sign-conversion -Wno-unused-const-variable
Then click OK. Now the unwanted warnings should go away.
If your project still isn't using the new settings, in the left bar of Qt Creator, click "Projects", then click "Clang Code Model", then at right, change the drop-down from "Use Global Settings" to "Use Customized Settings."
If you ever decide that you want to turn off the Code Model feature entirely, in Qt Creator click: Help -> About Plugins … -> C++, then uncheck "ClangCodeModel".