Recommended Settings for Qt Creator


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:

Build & Run settings

We recommend checking the following boxes:

Debugger settings

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/X style guide.

In Qt Creator's preferences, go to the Analyzer area, then in the initial Clang Tools tab, find the area labeled "Diagnostic Configuration", and click "Manage…" 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 106BX 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" tab, replace the existing text with this text:

-Wall -Wextra -Wcast-align -Wfloat-equal -Wformat=2 -Wlogical-op -Wno-missing-field-initializers -Wno-old-style-cast -Wno-sign-compare -Wno-sign-conversion -Wno-write-strings -Wreturn-type -Werror=return-type -Werror=uninitialized -Wunreachable-code -Wno-keyword-macro -Wno-reserved-id-macro -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 "Global" to "Custom", and choose your "CS 106BX settings" from the list.

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".