如何操作
以下主题介绍了如何使用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 Zen Mode
- 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
- Build with GN
- 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 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 版本以及调试器命令。
如何管理套件
运行项目
在本地和远程桌面系统上运行应用程序,以及在连接到计算机的嵌入式和移动设备上运行应用程序。
如何运行应用程序
配置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
设计用户界面
使用Qt Quick 或Qt Widgets,通过Design 模式中的集成可视化编辑器设计用户界面。
设计Qt Quick 用户界面
Qt Creator 会自动在集成的Qt Quick Designer中以Design 模式打开UI表单(.ui.qml )文件。
如何设计Qt Quick 用户界面
- Add assets
- Add designs from Figma to Qt
- 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
使用 UI 组件
导入 Qt Qml 模块,以便在应用程序中使用其 Qml 类型的实例。
如何使用 UI 组件
- 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
添加动画
从一系列适用于不同用途的动画技术中进行选择
如何为 UI 组件添加动画
与各州合作
设计基于小部件的用户界面
Qt Creator 会自动在集成的Qt Widgets Designer中以Design 模式打开所有.ui 文件。
如何设计基于控件的用户界面
为设备开发
在计算机上安装用于为目标嵌入式或移动平台构建应用程序的工具链,并使用Qt Online Installer 安装针对该平台构建的 Qt 库。然后添加一个包含该工具链以及与设备架构对应的 Qt 版本的套件。在可能的情况下,Qt Online Installer 会为您自动生成合适的套件。 将设备连接到计算机,以便在设备上运行、调试和分析应用程序。
Android
安装适用于 Android 的 Qt及 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
在未被远程 Linux 设备插件支持的小型 Linux 设备上,使用 GDB 或硬件调试器运行和调试应用程序。
如何为裸机设备进行开发
Boot to Qt
在 Boot to Qt 设备上运行、调试和分析应用程序。
如何为Boot to Qt 设备进行开发
Docker
基于Docker 镜像创建Docker 设备,并利用它们来构建、运行和调试应用程序。
如何为 Docker 设备进行开发
iOS
安装适用于 iOS 的 Qt和 Xcode,并将 iOS 设备连接到计算机。
如何为 iOS 设备进行开发
微控制器
安装 Qt for MCUs,并将微控制器连接到计算机。
QNX Neutrino
安装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,用于构建 Web 应用程序并在 Web 浏览器中运行它们。
Windows 桌面
使用 Windows App SDK 的组件和工具开发应用程序。
如何进行 Windows 桌面开发
编辑代码
代码编辑器提供了用于编辑 C++ 和 QML 代码的实用功能,例如语义高亮、语法检查、代码补全和快速修复。其中一些功能也适用于其他编程语言,例如 Python——该语言提供了一个语言服务器,可向集成开发环境(IDE)提供代码相关信息。
如何编辑代码
- 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
- 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
使用人工智能
与了解您的代码库并能代表您执行操作(例如编辑文件、运行命令或触发构建)的 AI 代理进行对话。
如何使用 AI
使用 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
- Manage remote repositories
- Review code with Gerrit
- Set up Git
- Set up version control systems
- Show instant blame
- Stage changes
- Use Git for Windows
- Use Git with Subversion
- Use common VCS functions
- git amend
- 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.