Quick Fixes

To set global preferences for C++ quick fixes, go to Preferences > C++ > Quick Fixes.

Function Locations

In the Generated Function Locations group, set whether quick fixes should generate getter and setter functions in the header file (inside or outside the class) or in the implementation file.

{Generated Function Locations group in Quick Fixes preferences}

Function Names and Attributes

In the Getter Setter Generation Properties group, specify additional settings for getter and setter names, attributes, and parameters. You can specify that setter functions should be created as slots and that signals should be generated with the new value as a parameter.

{Getter and Setter generation settings}

Namespace Handling

In the Missing Namespace Handling group, select whether to generate missing namespaces, add using namespace where necessary, or rewrite types to match the existing namespaces.

"Namespace handling settings"

Custom Parameter Types

In the Custom Getter Setter Templates group, specify how the code of a getter or setter function for a certain data type should look like. This is necessary for types where assignment cannot use operator=, as in the pre-defined settings for unique_ptr or where operator== is not suitable for comparison, as in the pre-defined settings for floating-point types. For example, if you have a special type MyClass, you can specify that a function, myCompare, should be used for comparison rather than the default of ==.

To specify special handling for a custom parameter type, select Add and set the parameter type, comparison, return expression, and return type. In the Return type field, use <new> and <cur> to access the parameter and current value. Use <type> to access the type and <T> for the template parameter.

{Settings for handling custom parameter types}

Usually, arguments are passed by using a const reference. To pass arguments of a particular type as values, list them in the Value types field. Namespaces and template arguments are removed. The real Type must contain the given Type. For example, int matches int32_t but not vector<int>, and vector matches std::pmr::vector<int> but not std::optional<vector<int>>.

To return non-trivial objects by using a const reference, select the Return non-value types by const reference check box.

See also Apply quick fixes, Find symbols, Rename symbols, Specify settings for quick fixes, C++ Quick Fixes, and QML Quick Fixes.

© 2024 The Qt Company Ltd. 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.