- Qt Design Studio Manual
- Applying Refactoring Actions
- Qt Design Studio Manual 2.3.0

Refactoring ◦ Configuring the Editor

# Applying Refactoring Actions

Qt Design Studio allows you to quickly and conveniently apply actions (quick fixes) to refactor your code by selecting them in a context menu. The actions available depend on the position of the cursor in the code editor.

To apply refactoring actions to QML code, right-click an item ID or name.

In the context menu, select Refactoring and then select a refactoring action.

You can also press Alt+Enter to open a context menu that contains refactoring actions available in the current cursor position.

## Summary of Refactoring Actions

You can apply the following types of refactoring actions to QML code:

- Rename IDs
- Split initializers
- Move a QML type into a separate file to reuse it in other .qml files

The following table summarizes the refactoring actions for QML code. The action is available when the cursor is in the position described in the Activation column.

Refactoring Action | Description | Activation
--- | --- | ---
Move Component into Separate File | Moves a QML type into a separate file. Give the new component a name and select whether properties are set for the new component or for the original one. | QML type name. This action is also available in Form Editor.
Split Initializer | Reformats a one-line type into a multi-line type. For example, rewrites
     Item { x: 10; y: 20; width: 10 }
as
     Item {
         x: 10;
         y: 20;
         width: 10
     }
| QML type property
Wrap Component in Loader | Wraps the type in a Component type and loads it dynamically in a Loader type. This is usually done to improve startup time. | QML type name
Add a message suppression comment | Prepends the line with an annotation comment that stops the message from being generated. | Error, warning or hint from static analysis

Refactoring ◦ Configuring the Editor