Use Qt AI Assistant
Qt AI Assistant is a coding assistant. When connected to a Large Language Model (LLM), it auto-completes your code, gives expert coding advice, suggests code fixes, as well as writes test cases and code documentation.
Qt AI Assistant is available for selected commercial Qt developer license holders. For more information on licensing, select Compare in Qt pricing.
Note: The LLM itself is not in scope of the Qt AI Assistant. You need to connect to a third-party LLM and agree to the terms and conditions, as well as to the acceptable use policy of the LLM provider. By using Qt AI Assistant, you agree to Terms & Conditions - Qt Development Framework.
Qt AI Assistant is currently experimental and powered by generative AI. Check all suggestions to make sure that they are fit for use in your project.
Note: Install and load the Qt AI Assistant extension to use it.
Connect to an LLM
You can connect to the following LLMs:
- Meta Code Llama 13B (running in a cloud deployment of your choice)
- Meta Llama 3.1 70B (running in a cloud deployment of your choice)
- Anthropic Claude 3.5 Sonnet (provided as subscription-based service by Anthropic)
- Meta Code Llama 7B through Ollama (running locally on your computer)
To connect to an LLM:
- Go to Preferences > AI Assistant > General.
- Select an LLM for each configurable use case.
- Go to Advanced.
- Enter the API authentication token and server URL of each LLM. For more information on where to get the access information, see the third-party LLM provider documentation.
Automatic code-completion
Qt AI Assistant can help you write code by suggesting what to write next. It prompts the LLM to make one code suggestion when you stop typing.
To accept the entire suggestion, select the Tab key.
To accept parts of the suggestions, select Alt+Right.
To dismiss the suggestion, select Esc or navigate to another position in the code editor.
To interact with Qt AI Assistant using the mouse, hover over the suggestion.
When you hover over a suggestion, you can accept parts of the suggested code snippet word-by-word or line-by-line.
To close the code completion bar, select the Esc key or move the cursor to another position.
To turn auto-completion of code on or off globally for all projects, go to Preferences > AI Assistant. Qt AI Assistant consumes a significant number of tokens from the LLM. To cut costs, disable the auto-completion feature when not needed, and use keyboard shortcuts for code completion.
Complete code from the keyboard
To trigger code suggestions manually, select Ctrl+'.
Enter prompts and smart commands
In an inline prompt window in the text editor, you can prompt the assistant to implement your requests in human language, ask questions, or execute smart commands. To open the chat, select Ctrl+Shift+A. Alternatively, to open the inline prompt window, you can select code and then select .
To close the inline prompt window, select Esc or .
To go to Qt AI Assistant preferences from the inline prompt window, select .
Request suggestions using human language
To request suggestions using human language, enter your requests into the input field. If you have highlighted code, the AI assistant adds it as context to the prompt. Qt AI Assistant shows a suggestion that you can copy to the clipboard by selecting Copy in the inline prompt window.
Request test cases in Qt Test syntax
To write test cases with Qt AI Assistant:
- Highlight code in the code editor.
- Open the inline prompt window.
- Select the /qtest smart command.
Qt AI Assistant generates a test case in Qt Test format that you can copy and paste to your Qt test project.
Request code documentation in Markdown format
To create code documentation:
- Highlight code in the code editor.
- Open the inline prompt window.
- Select the /doc smart command.
Qt AI Assistant generates code documentation in a format that you can copy and paste to your documentation file.
Request fixing of code
To request a fix to your code:
- Highlight code in the code editor.
- Open the inline prompt window.
- Select the /fix smart command.
Qt AI Assistant writes a suggestion for a fix of your code.
Request explaining of code
To request an explanation of existing code:
- Highlight code in the code editor.
- Open the inline prompt window.
- Select the /explain smart command.
Qt AI Assistant provides an explanation of the highlighted code.
See also Install extensions and Load extensions.
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.