目录
Qt Creator中的 snippets (片段;片断;小片)
QtCreator snippets 占位符(Qt Creator Variables 、环境变量等)(****)
Qt代码提示速度慢,没有提示,无法补全解决办法
Qt官方文档:Snippets for Editors
迁移:snippets.xml (****)
---------------------------------------------------
要点:
1. snippets (片段) 与 Completion (补全) 是联动的。
2. Qt 默认了输入 第3个字符时,会自动调出 自动补全菜单。
当输入只有 2个字母 (如 if ) 时,则需要使用 自动补全快捷键 来完成。
3. 一些功能,是没有菜单入口的,需要使用快捷键。
存在快捷键冲突问题。
如果都有菜单入口的话,那么,这个菜单也太庞大了,甚至是无法实现这样的菜单,因为自定义的功能模块,是无法预料的。
问题:
需要修改快捷键:自动补全快捷键与 OS默认的发生冲突时。
迁移:
用户在修改过之后的 snippets.xml 文件,存放在:
debian:
/home/abc_user/.config/QtProject/qtcreator/snippets/snippets.xml
win:
C:\Users\abc_user\AppData\Roaming\QtProject\qtcreator\snippets\snippets.xml
snippets.xml 的结构:
<?xml version="1.0" encoding="UTF-8"?>
<snippets>
<snippet group="C++" trigger="qDebug" id="" complement="aaa" removed="false" modified="false">qDebug()</snippet>
</snippets>
---------------------------------------------------
参考:
Linux下QTCreator代码自动补全(是真的自动补全,不是手动触发)
qt creator插入代码块快速注释snippets代码片段的功能
https://blog.csdn.net/weixin_41761608/article/details/119773689
=============================
Qt官方文档
Snippets for Editors
Snippets typically consist of chunks of code in a programming language (although they can also be plain text) which you would like to avoid re-typing every time. They are triggered in the same way as the completions (see Providing Code Assist).
In order to create a new group of snippets two steps are necessary:
- Register the group with
TextEditor::SnippetProvider::registerGroup
- Create an XML configuration file and place it in the
/share/qtcreator/snippets directory.
- As an example of the file format please take a look at the already available ones. The meaning and consistency rules of the fields are described below:
- group - This is the group in which the snippet belongs in the user interface. It must match TextEditor::SnippetProvider::groupId().
- id - A unique string that identifies this snippet among all others available. The recommended practice is to prefix it with the group so it is easier to have such control on a file level.
- trigger - The sequence of characters to be compared by the completion engine in order to display this snippet as a code assist proposal.
- complement - Additional information that is displayed in the code assist proposal so it is possible to disambiguate similar snippets that have the same trigger.
All XML configuration files found in the directory mentioned above are parsed by Qt Creator. However, only the ones which are associated with known groups (specified by a provider) are taken into consideration.
snippets (片段) 与 Completion (补全) 是联动的。
snippets:设置具体的代码片段。
Completion:设置代码片段 snippets的调出 (补全) 方式。
QtCreator snippets 占位符(Qt Creator Variables 、环境变量等)
license 占位符记录:
%YEAR%: Year
%MONTH%: Month
%DAY%: Day of the month
%DATE%: Date
%USER%: Username
%FILENAME%: File name
%CLASS%: Class name (if applicable)
%$VARIABLE%: Contents of environment variable VARIABLE
QtCreator snippets 占位符(Qt Creator Variables 、环境变量等)_备忘录.的博客-CSDN博客
==========================
举例:添加作者信息的代码段
‘’‘
/*
author: author name
email: my email
company:my compony
complete date: %{CurrentDate:ISO}
$other info$*/
’‘’
配置输入字符串的大小写:
:c 首字母大写
:l 全部小写
:u 全部大写
如$name:c$
说明:
$name$:表示在选择了条目之后,光标定位到该name上,并且所有标记为$name$的变量都会跟着一起改变。其中的name可以改为其它变量名。你还可以定义多个变量,使用tab键,在多个变量之间切换。
$$:也是变量,只是它没有名字罢了。“触发”表示为文本的名字,“触发种类”可以进一步区分“触发”,并且形成一个列表供用户自由选择。
————————————————
版权声明:本文为CSDN博主「天地之心online」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_17246289/article/details/120223984
Qt Creator中的 snippets (片段;片断;小片)
Qt代码提示速度慢,没有提示,无法补全解决办法
https://blog.csdn.net/qq_42919993/article/details/123912977