应用快速修复
要在重构代码时应用快速修复,请在代码编辑器的上下文菜单中选择它们。可用的修复取决于光标在代码编辑器中的位置。
- 应用快速修复
- 在 C++ 代码中,右键单击操作数、条件语句、字符串或名称。
- 在 QML 代码中,右键单击项目 ID 或名称。
- 在上下文菜单中,转到Refactoring ,然后选择快速修复。
或者,选择Alt+Enter打开上下文菜单,其中包含当前光标位置可用的快速修复。
默认情况下,重构后的文件会自动保存。要关闭此功能,请转到首选项>Environment >System ,然后清除Auto-save files after refactoring 。
创建函数
应用快速修复功能来实现成员函数、插入基类的虚拟函数、创建 getter 和 setter 函数以及生成构造函数。在项目的构建和运行设置中,为所有项目全局生成函数或为每个项目单独生成函数指定设置。
实现成员函数
应用Create Implementations for Member Functions 快速修复,一次性创建所有成员函数的实现。在Member Function Implementations 对话框中,指定成员函数是在类内还是类外生成。
插入虚拟函数
应用Insert Virtual Functions of Base Classes 快速修复,在类内部或外部或在实现文件(如果存在)中插入声明和相应定义。
在可用函数列表中选择要插入的函数。过滤列表并隐藏重新实现的函数。
可以在函数声明中添加虚函数或重载函数。
创建获取器和设置器
应用Create Getter and Setter Member Functions 快速修复功能,为成员变量创建 getter 和 setter 成员函数,或者只创建 getter 或 setter。
生成构造函数
应用Generate Constructor 快速修复为类创建公共、受保护或私有构造函数。选择要在构造函数中初始化的类成员。拖动参数以指定它们在构造函数中的顺序。
将类移动到独立文件
应用Move Class to a Dedicated Set of Source Files 快速修复功能,将类移动到一组单独的头文件和实现文件中。
为头文件和实现文件指定路径和文件名。
要省略实现文件,请选择Header file only 。
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.