To get a trial key
fill out the form below
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
USD
EUR
RUB
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
** By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
** By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
** By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
How to use PVS-Studio in Qt Creator
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Diagnosis of micro-optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Problems related to code analyzer
Additional information
Contents

How to use PVS-Studio in Qt Creator

Dec 07 2021

Analysis of QMake projects

Such projects can be analyzed through the built-in compile_commands.json file generation mechanism.

Analysis of projects based on CMake

You can use the PVS-Studio analyzer to check CMake projects in the Qt Creator environment.

Before using the CMake module, you must enter the PVS-Studio license by running one of the following commands:

  • For Windows
"C:\Program Files (x86)\PVS-Studio\CompilerCommandsAnalyzer.exe" \
  credentials NAME XXXX-XXXX-XXXX-XXXX
  • For Linux and macOS
pvs-studio-analyzer credentials NAME XXXX-XXXX-XXXX-XXXX

Then add the PVS-Studio CMake module to the project. After that, add the code to the CMakeLists.txt file of the project to create the analysis target:

include(PVS-Studio.cmake)
pvs_studio_add_target(TARGET ${PROJECT_NAME}.analyze ALL
                      OUTPUT
                      FORMAT errorfile
                      ANALYZE ${PROJECT_NAME}
                      MODE GA:1,2
                      LOG ${PROJECT_NAME}.log
                      ARGS -e C:/Qt/
                      HIDE_HELP)

By default, when you open CMakeLists.txt of a project, Qt Creator hides additional build targets. To display them, disable the 'Hide Generated Files' option in project explorer filters:

QtCreator/image1.webp

To build and run the analysis, click Build "ProjectName.Analyze" from the analysis target context menu:

QtCreator/image3.webp

After the analysis is complete, errors found by the analyzer will be added to the 'Issues' pane:

QtCreator/image5.webp

View Report under Windows with MSVC Kit

If you are using the MSVC toolkit to build projects on Windows, Qt Creator will change the warning parser to be compatible with the output of Visual Studio compilers. This output format is incompatible with the PVS-Studio output formats. As the result, the analyzer messages will not appear in the 'Issues' pane. To configure support for the errorfile format, follow these steps:

  • Switch to the 'Projects' mode (Ctrl + 5). In the 'Build & Run' section, select the desired Kit. At the bottom of the page, in the 'Custom Output Parsers' section, click on the 'here' link.
QtCreator/image7.webp
  • In the opened window, click the 'Add...' button. In the 'Error message capture pattern' lines, insert the following regular expressions:

For the Error tab

(.*):(\d+): error: (.*)

For the Warning tab

(.*):(\d+): warning: (.*)

Alternatively, if you want to display low level warnings

(.*):(\d+): (?:warning|note): (.*)
QtCreator/image9.webp
  • After configuring the regular expressions, click 'Ok'. Select a new parser and restart analysis.
QtCreator/image11.webp

As a result, the analyzer warnings will appear in the 'Issues' pane.

QtCreator/image12.webp
Unicorn with delicious cookie
Our website uses cookies to enhance your browsing experience. Would you like to learn more?
Accept