Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change brace coding style in QtCreator

I want to change the braces coding style in Qt Creator 2.7.1. Currently, it is:

void bar(int i)
{
    static int counter = 0;
    counter += i;
}

But I want to change it to:

void bar(int i) {
    static int counter = 0;
    counter += i;
}

If I go to Options -> C++ -> Edit -> Braces, I can only change the indent of the braces. Changing the position of the braces manually in the preview text field, doesn't take any effect.

like image 529
Niklas Avatar asked Jul 24 '13 18:07

Niklas


2 Answers

I've opened public suggestion at Qt Creator bug tracker -- https://bugreports.qt.io/browse/QTCREATORBUG-11033.

Think, that it would be more helpful to pay more attention to bug tracker.

Hope, this feature will be added in Qt Creator 3.0.

like image 167
tro Avatar answered Sep 17 '22 18:09

tro


I just found a plugin for this. Called Artistic Style Plugin for Qt here the web.

Installation

  1. Download plugin specified for your qtcreator version (for 2.7.1, download 2.7.0 version but it need to be modified on later step).
  2. Unpack the package, and edit file ArtisticStyle.pluginspec.
  3. Edit the dependencies version description (on 2nd-step file) into the-already-installed version on your machine. On terminal (Ctrl+Alt+T), send qtcreator -version to get the info of Qt' dependencies version.

for example :

This one version description for 2.7.0

<dependency name="Core" version="2.7.0"/>
<dependency name="TextEditor" version="2.7.0"/>
<dependency name="ProjectExplorer" version="2.7.0"/>
<dependency name="Qt4ProjectManager" version="2.7.0"/>

to this one (for 2.7.1)

<dependency name="Core" version="2.7.1"/>
<dependency name="TextEditor" version="2.7.1"/>
<dependency name="ProjectExplorer" version="2.7.1"/>
<dependency name="Qt4ProjectManager" version="2.7.1"/>
  1. Follow the normal step from the website to install the plugin.

  2. If it has been installed, change the style through Preference->Artistic...->Style

  3. Add your own style and add --style=java

  4. Here you go.!

like image 32
Abdillah Avatar answered Sep 20 '22 18:09

Abdillah