Completing CodeAs you write code, Qt Creator suggests properties, IDs, and code snippets to complete the code. It provides a list of context-sensitive suggestions to the statement currently under your cursor. Press Tab or Enter to accept the selected suggestion and complete the code. To open the list of suggestions at any time, press Ctrl+Space. If only one option is available, Qt Creator inserts it automatically. When completion is invoked manually, Qt Creator completes the common prefix of the list of suggestions. This is especially useful for classes with several similarly named members. To disable this functionality, uncheck Autocomplete common prefix in the code completion preferences. Select Tools > Options... > Text Editor > Completion. By default, code completion considers only the first letter case-sensitive. To apply full or no case-sensitivity, select the option in the Case-sensitivity field. Summary of Available TypesThe following table lists available types for code completion and icon used for each.
Completing Code SnippetsCode snippets can consist of multiple variables that you specify values for. Select an item in the list and press Tab or Enter to complete the code. Press Tab to move between the variables and specify values for them. When you specify a value for a variable, all instances of the variable within the snippet are renamed. Code snippets specify C++ or QML code constructs. You can add, modify, and remove snippets in the snippet editor. To open the editor, select Tools > Options... > Text Editor > Snippets. Qt Creator provides you with built-in snippets in the following categories: Select a snippet in the list to edit it in the snippet editor. To add a new snippet, select Add. Specify a trigger and, if the trigger is already in use, an optional variant, which appear in the list of suggestions when you write code. Also specify a text string or C++ or QML code construct in the snippet editor, depending on the snippet category. The snippet editor provides you with: Specify the variables for the snippets in the following format: $variable$ Use unique variable names within a snippet, because all instances of a variable are renamed when you specify a value for it. The snippet editor does not check the syntax of the snippets that you edit or add. However, when you use the snippets, the code editor marks any errors by underlining them in red. To discard the changes you made to a built-in snippet, select Revert Built-in. Several similar built-in snippets might be provided for different use cases. To make the list of suggestions shorter when you write code, remove the built-in snippets that you do not need. If you need them later, you can restore them. To remove snippets, select a snippet in the list, and then select Remove. To restore the removed snippets, select Restore Removed Built-ins. To remove all added snippets and to restore all removed snippets, select Reset All. Note: If you now select OK or Apply, you permanently lose all your own snippets. [Previous: Checking Code Syntax] [Next: Indenting Code] © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. X
|