How to use Clang Static Analyzer on file save Qt Creator - qt-creator

The only way I've found out how to run Clang Static Analyzer in Qt Creator was by clicking on it in the menu. Is there a way to configure it so that it runs automatically when I save a file? If not, is there some way to lint the code upon file save with a plugin or something like that?

Related

Split window upon new C++ class creation in QtCreator

Is it possible to customize QtCreator to make it automatically split editor with header and code files upon creating new C++ class in QtCreator?
It's not exactly what you asked for but did you know about the OpenHeaderSourceInNextSplit command (Ctrl+E,F4)? As the wizard opens up the cpp file automatically it might be good enough to hit that after creation.
Alternatively, You might be able to achieve it by creating a custom wizard?

How to run a make file on save in VS Code - using go extension

How can I run a make build on save in VS Code on save event?
I can see that I can do something like the following.
{
"go.buildOnSave": "workspace"
}
I guess the lack doc. is be cause it is just basic VS Code - on setting a command.
How can I run a make build on save in VS Code on save event?
The Build, Lint and Vet of the VSCode Go extension from Microsoft (v1.26) currently based on go build. You can choose the preset option for package (default), workspace, or off. See vscode-go/goBuild.ts
If you would like to have a custom build i.e. make build on your workspace, you can set VSCode Custom Tasks instead.

Per file compiler flags in Xcode 8.1

I need to add some specific compiler flags only for certain files in my project. I did some googling and found out that this used to be possible in the file inspector in older Xcode versions. I'm on Xcode 8.1, however, and I can't seem to find where I can add custom compiler flags for certain files.
Could anybody please tell me how this is possible with Xcode 8.1?
Go to the navigation bar of your project
Click on your project
Click on the target you want to modify
Click on Build Phases
Look for the file you want to add the compiler flag in the Compile Sources list; in this list you should see two columns: name and compiler flags
Click on the latter column and a popup window should come up; add the compiler flags to that specific file

How can I add a resource to .qmlproject

I have created a new qmlproject using New File or Project… / Applications / Qt Quick 2 UI with Controls. I'd like to add resources (such as image files and fonts) to the project.
When I rightclick on the project, the entry Add Existing Files… is greyed out.
When I choose Add New… / Qt / Qt Resource file, Qt Creator creates a new resource file, but then pops up an error message that the file could not be added to the project.
When I drag an existing file from Finder to the project, Qt Creator open the file in a hex editor, but does not add it to the project.
I could not find any documentation on this, so this is why I would like to know: what is the standard way for adding a resource to a .qmlproject?
I'm using the version of Qt Creator bundled with Qt 5.2.0 beta 1
I don't think you can.
The type of project wizard you chose is documented here:
Qt Quick UI (in the Other Project category) creates a Qt Quick UI project with a single QML file that contains the main view. You can review Qt Quick UI projects in a preview tool and you need not build them. They do not contain any C++ code.
Qt Quick Controls UI is like Qt Quick UI, but using Qt Quick Controls.
The part in bold is key here, because .qrc files must be compiled into the application's executable, which can't happen when you don't have any C++ files to compile. Even if you had external binary resources, there's no QML API to register them as far as I'm aware; only C++.
Newer versions of Creator seem to recommend against it:
Creates a Qt Quick 2 UI project using Qt Quick Controls with a QML entry point. To use it, you need to have a QML runtime environment such as qmlscene set up. Consider using a Qt Quick Controls Application project instead.
I wouldn't recommend using the .qmlproject format. From memory, the last time I tried to deploy such a project to e.g. an Android device, it didn't work. You're better off using the "Qt Quick Application"/"Qt Quick Controls Application" project.

Compile one file in QT Creator

How to compile only one file from project in QT creator.
Is there a hotkey?
For example in VS you can press Ctrl F7 and compile your current cpp file.
It is now possible to do it, since at least Qt Creator 2.8.1.
Use Build->Build file <filename> or the shortcut Ctrl+Alt+B:
Or right click on a file in the project view, and there is a Build item in the context menu that builds just that file:
You can track the feature request or vote for it at https://bugreports.qt.io/browse/QTCREATORBUG-106.
Normally if you hit CTRL + B, Qt Creator will call make, which will in turn compile any files that have been modified since you compiled the last time. AFAIK there is no designated key for re-building the current file.
However, all Keystrokes can be configured in the application preferences General -> Keyboard. There are also a number of interesting other commands you might find useful.

Resources