Add code snippets to the auto-complete menu

To add code or text snippets in the snippet editor:

  1. Select Preferences > Text Editor > Snippets.

    {Snippets preferences}

  2. In Group, select the type of snippet to add.
  3. Select Add.
  4. Specify a trigger. If the trigger is already in use, add an optional variant. They 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.

    You can use predefined variables in snippets.

See also Complete CMake code, Complete code, Use Qt Creator variables, Nim, Completion, and Snippets.

© 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.