本页内容

粘贴和获取代码片段

若要将代码片段或整个文件粘贴到服务器上,或从服务器获取它们,请使用以下任一代码粘贴服务:

  • DPaste.com
  • Pastebin.com

例如,您可能需要请同事审查您计划提交到版本控制系统的更改。如果您使用 Git 版本控制系统,请访问Tools >Git >Local Repository >Diff 生成差异视图。然后,访问Tools >Code Pasting >Paste Snippet 将内容上传至服务器。

审阅者可通过选择Tools >Code Pasting >Fetch Snippet 来检索该代码片段。如果他们当前已在Qt Creator 中打开该项目,则可通过访问Tools >Git >Local Repository >Patch >Apply from Editor 来应用并测试该更改。

粘贴代码片段

要将代码片段粘贴到服务器上:

  1. 前往Tools >Code Pasting >Paste Snippet 或按Alt+C,Alt+P

    “发送至 Codepaster”对话框

  2. Protocol 中,选择要使用的代码粘贴服务。
  3. 在“Expires after ”中,指定已粘贴代码片段在服务器上的保留时间。
  4. UsernameDescription 中,输入您的用户名并添加有关粘贴内容的信息。
  5. 检查并编辑待粘贴的内容。
  6. 选择Paste

默认情况下,“Qt Creator ”会将代码片段的 URL 复制到剪贴板,并在“General Messages ”中显示该 URL。

要粘贴差异,请右键单击一个代码块,并在上下文菜单中选择“Send Chunk to CodePaster ”。

获取代码片段

要从服务器获取代码片段:

  1. 转到“Tools ” > “Code Pasting ” > “Fetch Snippet ”,或按Alt+C,Alt+F
  2. 从列表中选择要获取的代码片段。

若要获取存储在某个 URL 中的内容,请选择“Tools ” > “Code Pasting ” > “Fetch from URL ”。

设置代码粘贴首选项

要设置代码粘贴服务的首选项:

  1. 转到“Preferences ” > “Code Pasting ” > “General ”。

    “代码粘贴”首选项中的“常规”选项卡

  2. Default protocol 中,选择一个要作为默认使用的代码粘贴服务。
  3. 在“Username ”中,输入您的用户名。
  4. Expires after 中,指定在服务器上保留已粘贴代码片段的时间。
  5. 选中“Copy-paste URL to clipboard ”,以便在粘贴帖子时将代码粘贴服务上该帖子的 URL 复制到剪贴板。
  6. 选择“Display General Messages after sending a post ”,以便在粘贴帖子时在“General Messages”中显示该 URL。

为代码粘贴设置共享网络驱动器

前往Preferences >Code Pasting >Fileshare ,指定共享网络驱动器的路径。

代码片段将作为普通文件复制到该驱动器中。您需要手动从驱动器中删除过时的文件。

另请参阅 “比较文件”和“使用 Git”。

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.