快速修复
要为 C++ 快速修复设置全局首选项,请转至首选项>C++ >Quick Fixes 。
函数位置
在Generated Function Locations 组中,设置快速修复是否应在头文件(类内部或外部)或实现文件中生成 getter 和 setter 函数。
函数名称和属性
在Getter Setter Generation Properties 组中,指定 getter 和 setter 名称、属性和参数的其他设置。您可以指定将 setter 函数创建为插槽,并将新值作为参数生成信号。
命名空间处理
在Missing Namespace Handling 组中,选择是否生成缺失的命名空间、在必要时添加using namespace
或重写类型以匹配现有命名空间。
自定义参数类型
在Custom Getter Setter Templates 组中,指定特定数据类型的 getter 或 setter 函数代码的外观。对于赋值不能使用operator=
的类型(如unique_ptr
的预定义设置),或者对于operator==
不适合比较的类型(如浮点类型的预定义设置),这是必要的。例如,如果有一个特殊类型MyClass
,可以指定使用一个函数myCompare
进行比较,而不是默认的==
。
要为自定义参数类型指定特殊处理,请选择Add 并设置参数类型、比较、返回表达式和返回类型。在Return type 字段中,使用<new>
和<cur>
访问参数和当前值。使用<type>
访问类型,使用<T>
访问模板参数。
通常,参数通过const
引用传递。要将特定类型的参数作为值传递,请在Value types 字段中列出。命名空间和模板参数将被删除。真实类型必须包含给定的类型。例如,int
与int32_t
匹配,但与vector<int>
不匹配;vector
与std::pmr::vector<int>
匹配,但与std::optional<vector<int>>
不匹配。
要使用const
引用返回非三维对象,请选择Return non-value types by const reference 复选框。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.