如何使用
以下主题介绍如何使用Qt Creator 执行特定任务。
调整用户界面
浏览Qt Creator 用户界面或更改其外观和行为。
如何调整用户界面
- Assign keyboard shortcuts
- Change the UI language
- Detach views
- Find keyboard shortcuts
- Find preferences
- Import and export keyboard shortcuts
- Preview images
- Set high DPI scaling
- Set the number of recent files shown
- Show and hide sidebars
- Show and hide the main menu
- Show task list files in issues
- Switch UI themes
- Switch between modes
- Use info bars instead of pop-ups
- View Squish output
- View application output
- View call hierarchy
- View class hierarchy
- View compile output
- View file system
- View include hierarchy
- View issues
- View open documents
- View outline
- View output
- View projects
- View search results
- View type hierarchy
分析
使用集成的代码分析工具来检测内存泄漏、剖析函数执行情况、分析 CPU 使用情况,并消除代码中不必要的复杂性。其他集成工具可提供代码覆盖率并可视化跟踪事件。
如何分析代码
- Analyze CPU usage
- Analyze code with Clang-Tidy and Clazy
- Check code syntax
- Configure Clang diagnostics
- Connect to Axivion dashboard servers
- Create compiler explorer sessions
- Detect errors in C++ code with Cppcheck
- Detect memory leaks with Heob
- Detect memory leaks with Memcheck
- Explore compiler code
- Local analysis with Axivion
- Profile CMake code
- Profile QML applications
- Profile function execution
- Run Valgrind tools on external applications
- Set global preferences for Clang tools
- Set up code coverage from Coco
- Specify Valgrind settings for a project
- View Axivion static code analysis results
- View code coverage reports from Coco
构建和运行
使用集成的跨平台自动构建系统,为不同的目标平台或使用不同的编译器、调试器或 Qt 版本编译源代码。将应用程序部署到目标平台并在那里运行。
如何构建和运行应用程序
- Activate custom output parsers
- Add custom output parsers
- Build for many platforms
- Configure development tools
- Configure projects for building
- Customize the build process
- Edit Qbs profiles
- Edit vcpkg manifest files
- Enable debugging
- Parse build output
- Set Qbs profile directory
- Set the default build and run directories
- Set up vcpkg package manager
- Use Development Containers
- Use MCP client
- Use compilation databases
- View compile output
使用 CMake 构建
CMake 通过使用简单的配置文件(称为CMakeLists.txt 文件)来控制软件编译过程。
如何使用 CMake 构建
- Add CMake tools
- Add libraries to CMake projects
- Complete CMake code
- Debug CMake project files
- Edit CMake configuration files
- Format CMake files
- Manage files in CMake projects
- Override CMake settings for a project
- Profile CMake code
- Read CMake documentation
- Use junction points on Windows
- View CMake project contents
使用 qmake 构建项目
qmake 可根据扩展名为.pro 的项目文件中的信息自动生成 Makefile。
如何使用 qmake 构建
管理工具包
Qt Creator 将构建和运行特定设置作为工具包分组,可使跨平台开发更轻松。每个工具包由一组定义环境的值组成,如要使用的设备、工具链、Qt 版本和调试器命令。
如何管理工具包
运行项目
在本地和远程桌面系统以及连接到计算机的嵌入式设备和移动设备上运行应用程序。
如何运行应用程序
- Configure projects for running
- Run Python applications
- Run in Qt Application Manager
- Run on QNX devices
- Run on remote Linux devices
- Run on the desktop
- Set the default build and run directories
- Specify Qt Quick UI Prototype run settings
- Specify a custom executable to run
- Use MCP client
- View application output
配置Qt Creator
使用Qt Creator 的基本功能以及预装的扩展和插件。安装更多扩展和插件并配置外部工具以供使用。
如何配置Qt Creator
- Activate extensions
- Collect usage statistics
- Configure the locator
- Contact Qt
- Enable and disable plugins
- Inspect internal logs
- Install extensions
- Install plugins
- Manage extensions
- Manage sessions
- Open a terminal
- Record screens
- Reset Qt Creator settings
- Run Qt Creator from the command line
- Set up screen recording
- Set up version control systems
- Turn on crash reports
- Use Qt Linguist
- Use common VCS functions
- Use external text editors
- Use external tools
创建项目
使用预设向导或自己的向导创建用于开发应用程序和库的项目。然后配置项目,以便在目标平台上构建和运行应用程序。
如何创建项目
- Add libraries to qmake projects
- Add subprojects to projects
- Add wizards
- Convert UI projects to applications
- Create Nimble projects
- Create Qt Interface Framework projects
- Create Qt Quick Applications
- Create Qt Quick UI Prototypes
- Create VCS repositories for new projects
- Develop Qt for Python applications
- Import an existing project
- Select the build system
- Use project wizards
添加文件
向项目添加文件。
如何在项目中添加文件
配置项目
更改安装程序和项目向导创建的默认配置,并覆盖特定项目的全局首选项。
如何配置项目
- Activate kits for a project
- Apply filters before scanning for tests
- Configure C++ code model
- Configure language servers for projects
- Configure projects for building
- Configure projects for running
- Edit environment settings
- Enable debugging
- Exclude files from to-do lists
- Link projects with GitLab
- Open projects
- Override CMake settings for a project
- Share project settings
- Specify Clang tools settings
- Specify build and run settings
- Specify clangd settings
- Specify dependencies
- Specify editor settings
- Specify project contents
- Specify settings for quick fixes
- Specify the environment for projects
- Use Qt Creator variables
调试
使用调试器在应用程序运行时检查其状态。
如何调试程序
- Add breakpoints
- Attach the debugger to running applications
- Attach the debugger to starting processes
- Debug C++ applications on VxWorks devices
- Debug CMake project files
- Debug crashed processes on Windows
- Debug on Android devices
- Debug remotely with CDB
- Debug remotely with GDB
- Examine complex values in Debug views
- Inspect basic Qt objects
- Load core files to the debugger
- Manage breakpoints
- Set data breakpoints
- Show tooltips for simple values
- Start and debug an external application
- Start debugging
- Start debugging from the command line
- Step through code
- Use MCP client
设计用户界面
在Design 模式下使用集成的可视化编辑器通过Qt Quick 或Qt Widgets设计用户界面。
设计Qt Quick 用户界面
Qt Creator 在Design 模式下,在集成的Qt Quick Designer 中自动打开 UI 窗体 (.ui.qml) 文件。
如何设计Qt Quick 用户界面
- Add assets
- Annotate designs
- Convert UI projects to applications
- Create Qt Quick Applications
- Create Qt Quick UI Prototypes
- Design 2D UIs
- Load placeholder data
- Navigate component files
- Open UI files in Qt Design Studio
- Preview Qt Quick UIs on devices
- Preview a QML file on desktop
- Run QML files
- Specify Qt Quick UI Prototype run settings
- Use custom fonts
- Use workspaces
使用用户界面组件
导入 Qt QML 模块,以便在应用程序中使用其 QML 类型的实例。
如何使用用户界面组件
- Add bindings between properties
- Add custom properties
- Add interaction to UIs
- Add text to UIs
- Change properties
- Connect components to signals
- Create buttons
- Create component instances
- Create custom components
- Create scalable buttons and borders
- Create shapes
- Import modules
- Insert UI controls
- Make layouts scalable
- Pick colors
- Pick gradients
- Set advanced component properties
- Set basic component properties
- Use images in UIs
- Use lists and other data models
- Use preset components
添加动画
从适用于不同目的的动画技术中进行选择
如何为用户界面组件制作动画
与各州合作
设计基于部件的用户界面
Qt Creator 在集成的Qt Widgets Designer 中以Design 模式自动打开所有.ui 文件。
如何设计基于 widget 的用户界面
为设备开发
在计算机上安装为目标嵌入式或移动平台构建应用程序的工具链,并使用Qt Online Installer 安装为该平台构建的 Qt XML 库。然后添加一个包含工具链和设备架构 Qt 版本的工具包。如有可能,Qt Online Installer 会为您创建合适的工具包。将设备连接到计算机,在上面运行、调试和分析应用程序。
安卓
安装Qt for Android和 Android 工具,并将 Android 设备连接到计算机。
如何为 Android 开发
- Add external libraries to Android packages
- Create Android packages
- Create an Android Virtual Device (AVD)
- Debug on Android devices
- Deploy applications to Android
- Edit Android manifest files
- Manage AVDs
- Manage Android NDK packages
- Manage Android SDK packages
- Set up Android development environment
- Sign Android packages
- Specify Android run settings
Bare Metal
使用 GDB 或硬件调试器,在远程 Linux 设备插件不支持的小型 Linux 设备上运行和调试应用程序。
如何为裸机设备开发
Boot to Qt
在设备上运行、调试和分析应用程序 Boot to Qt设备上运行和分析应用程序。
如何为Boot to Qt 设备开发
Docker
从Docker 映像创建Docker 设备,并用它们来构建、运行和调试应用程序。
如何为 Docker 设备开发
iOS
安装Qt for iOS和 Xcode,并将 iOS 设备连接到计算机。
如何为 iOS 设备开发
微控制器
安装 Qt for MCUs将微控制器连接到计算机。
QNX 中微子
安装Qt for QNX,并将 QNX Neutrino 设备连接到计算机。
如何为 QNX Neutrino 设备进行开发
远程 Linux
为通用 Linux 设备构建应用程序的工具链添加工具包,并将设备连接到计算机。
如何为远程 Linux 设备开发
- Add remote Linux devices
- Build applications on remote Linux devices
- Configure SSH connections
- Configure development tools
- Connect remote Linux devices
- Debug remotely with GDB
- Deploy applications to remote Linux devices
- Generate SSH keys
- Manage device processes
- Run on remote Linux devices
- Specify remote Linux run settings
VxWorks
为 VxWorks 构建Qt,创建 VxWorks 构建和运行工具包。
如何为 VxWorks 构建应用程序
WebAssembly
安装Qt for WebAssembly,为网络构建应用程序并在网络浏览器中运行。
Windows 桌面
使用 Windows App SDK 的组件和工具开发应用程序。
如何为 Windows 桌面开发
编辑代码
代码编辑器提供编辑 C++ 和 QML 代码的实用功能,如语义高亮显示、检查代码语法、代码补全和快速修复。其中一些功能也适用于其他编程语言,如 Python,它的语言服务器可向集成开发环境提供有关代码的信息。
如何编辑代码
- Add to-do keywords
- Apply quick fixes
- Automatically format QML/JS files
- Bookmark code
- Compare files
- Complete code
- Create Lua scripts
- Document code
- Download highlight definitions
- Edit Markdown files
- Edit properties of QML types
- Enclose code in brackets or quotes
- Highlight code blocks
- Indent text or code
- Insert multiple cursors
- Inspect the code model
- Locate files using the keyboard
- Move between files
- Move in QML code
- Move to symbols
- Parse files
- Paste and fetch code snippets
- Paste text from clipboard history
- Perform calculations
- Preview images
- Record text editing macros
- Select the current code block
- Specify Qt Quick code style
- Split the editor view
- Switch to Edit mode
- Use GitHub Copilot
- Use Qt AI Assistant
- Write down notes
配置编辑器
通过更改字体、颜色、高亮显示和缩进来配置代码和文本编辑器,以满足您的特定需求。
如何配置编辑器
管理语言服务器
配置Qt Creator 默认添加的语言服务器或添加更多语言服务器。
如何管理语言服务器
搜索
使用增量搜索和高级搜索可搜索当前打开的项目或文件系统中的文件,或使用定位器浏览项目、文件、类、函数、文档和文件系统。
如何搜索
编辑状态图
使用文件向导创建带有模板代码的状态图 XML (SCXML) 文件,并使用 SCXML 编辑器进行编辑。
如何编辑状态图
编辑 UML 风格模型
用结构图和行为图创建通用建模语言(UML)风格的模型,为系统提供不同的视图。
如何编辑模型和图表
阅读文档
Qt Creator 集成了您安装的 Qt 版本的参考文档。您还可以添加其他来源的文档。
如何获取帮助
测试
创建和运行基于代码的测试,并构建基于系统的测试。基于代码的测试为特定的测试框架提供了特殊的处理方法,与底层代码模型或专门的解析器紧密相连。基于构建系统的测试独立于任何测试框架。它直接从底层构建系统中获取信息,并使用这些信息甚至构建系统来执行相应的测试。
如何测试应用程序
- Add tests to existing test projects
- Apply filters before scanning for tests
- Build and run tests
- Connect to Squish Server
- Create Boost tests
- Create CTest Based Tests
- Create Catch2 tests
- Create Google tests
- Create Qt Quick tests
- Create Qt tests
- Create Squish test suites
- Manage Squish test suites and cases
- Select Squish AUTs
- View Squish output
- View test results
使用 Git
Git 是一种快速的分散式版本控制系统,适用于 Windows、Linux 和 macOS。你可以在使用 Git 的项目中使用Gerrit 代码审查工具。
如何使用 Git
- Apply actions to commits
- Commit your first change
- Create VCS repositories for new projects
- Create and apply patches
- Git Tools
- Initialize Git repositories
- Interactive rebase
- Review code with Gerrit
- Set up version control systems
- Show instant blame
- Stage changes
- Use Git for Windows
- Use Git with Subversion
- Use common VCS functions
- git am
- git blame
- git branch
- git clean
- git commit
- git diff
- git fetch
- git log
- git merge
- git pull
- git push
- git reflog
- git reset
- git stash
- git status
当前文件
如何处理当前文件中的更改
当前项目
如何处理当前项目中的变更
本地软件库
如何管理本地存储库
提交
如何处理提交
远程软件源
如何管理远程版本库
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.