有没有办法在 QT Creator 中完全自定义首选编码风格?
这就是我的意思(我将直接使用来自 Qt creator 设置的示例代码的一部分):
class Complex
{
public:
Complex(double re, double im)
: _re(re), _im(im)
{}
double modulus() const
{
return sqrt(_re * _re + _im * _im);
}
private:
double _re;
double _im;
};
我希望它变成:
class complex // <- lower latter
{
public:
complex( double re, double im ) // <- spaces after/before ()
: // <- new line
_re( re ), // <- spaces after/before ()
_im( im ) // <- new line and spaces after/before ()
{
} // <- new line
// <- new line
double modulus() const
{
return sqrt( _re * _re + _im * _im ); // <- spaces after/before ()
}
// <- new line
private:
double _re;
double _im;
};
等等,你明白了。
是否有一些插件或者是否有一些“手动”方法来实现这个?许多其他编辑器都有此选项(例如,eclipse 和 slickedit)
编辑:啊,我刚看到this coding style和 these coding conventions .这是否意味着我不能使用我自己的编码风格,即使是只使用 QT 的代码?
此外,我知道工具 -> 选项 -> C++ -> 代码风格
-> 复制然后编辑,但是它非常有限。例如,我不能修改任何的东西,在上面的例子中被标记为 c++ 注释。
最佳答案
是的,Beautifier插件可以做到这一点。它集成在 QtCreator 3.*.*
要启用它,请转到“帮助 -> 关于插件...”,然后选中“C++”组中的“美化器”框。
它使用外部工具并且只能使用这三个:Clang-format (llvm/tools 的一部分),Uncrustify和 Artistic Style ,因此您必须至少安装其中一个。
安装后,您可以选择流行的样式(例如 K&R、Google、GNU)或提供您自己的配置文件。为了方便起见,您可以使用 UniversalIndentGUI .
您可能还对一些 style choices 感兴趣.
关于c++ - 完全自定义 Qt Creator 编码风格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22846739/