Qt

Pasting and Fetching Code Snippets

In Qt Creator, you can paste snippets of code to a server or fetch snippets of code from the server. To paste and fetch snippets of code, Qt Creator uses the following:

  • CodePaster
  • Pastebin.Com
  • Pastebin.Ca
  • Paste.KDE.Org
  • Shared network drives

To configure the server, select Tools > Options > Code Pasting > CodePaster. In the Server field, specify the host name of the CodePaster service.

Select Fileshare to specify the path to a shared network drive. The code snippets are copied to the drive as simple files. You have to delete obsolete files from the drive manually.

To paste a snippet of code onto the server, select Tools > Code Pasting > Paste Snippet or press Alt+C,Alt+P. By default, Qt Creator copies the URL of the snippet to the clipboard and displays the URL in the Output pane.

To fetch a snippet of code from the server, select Tools > Code Pasting > Fetch Snippet or press Alt+C,Alt+F.

To fetch content from a URL on a CodePaster service, select Tools > Code Pasting > Fetch from URL. The content is opened in the code editor.

Note: To use Pastebin.Com, configure the domain prefix in Tools > Options > Code Pasting > Pastebin.com.

For example, you might ask colleagues to review a change that you plan to submit to a version control system. If you use the Git version control system, you can create a diff view by selecting Tools > Git > Diff Repository. You can then upload its contents to the server by choosing Tools > Code Pasting > Paste Snippet. The reviewers can retrieve the code snippet by selecting Tools > Code Pasting > Fetch Snippet. If they have the project currently opened in Qt Creator, they can apply and test the change by choosing Tools > Git > Apply Patch.