Alex Rivera | Logout

QtCreator: Central "header" for source code (copyright, author)

Asked 2012-09-05T10:29:37.300
10

Is there a chance to define a central header (remark) being included in all source code files (automatically) in QtCreator?

The header shall contain just a remark with legal information, copyright, web site of the project etc.

I want to keep it in one central place in order I need to change it. If I manually add it to each .h / .cpp file, I need to change it everywhere in case I want to make adjustments.

Edit
Report

1 Answer

11

The closest thing you can do is to add a licence template (Options -> C++ -> File naming -> License template) like this:

/***************************************************************************
 *                                                                         *
 *   Copyright (C) %YEAR% by CompanyName                                   *
 *                                                                         *
 *   http://CompanyName.com                                                *
 *                                                                         *
 ***************************************************************************/

Creator will prepend this file when creating a source or an header file, replacing %YEAR% with the current year (there might possibly be other place holders).

But if you want to change this notice on already existing files you will have to do by hand (it should not be hard to write a simple regex to do that).

answered 2012-09-05T11:03:45.833

Your Answer