如何使用
以下主题介绍了如何使用Qt Creator 执行特定任务。
分析
使用集成的代码分析工具来检测内存泄漏、剖析函数执行情况、分析 CPU 使用情况并消除代码中不必要的复杂性。其他集成工具可提供代码覆盖率和可视化跟踪事件。
- Analyze CPU usage
- Analyze code with Clang-Tidy and Clazy
- Check code syntax
- Configure Clang diagnostics
- 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 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 projects for building
- Customize the build process
- Edit Qbs profiles
- Edit vcpkg manifest files
- Enable debugging
- Use compilation databases
使用 CMake 进行编译
CMake 通过使用简单的配置文件(称为CMakeLists.txt文件)来控制软件编译过程。
- 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
- View CMake project contents
使用 qmake 生成
qmake 可根据扩展名为.pro 的项目文件中的信息自动生成 Makefile。
运行应用程序
在本地和远程桌面系统上运行应用程序,以及在连接到计算机的嵌入式设备和移动设备上运行应用程序。
- Configure projects for running
- Run Python applications
- Run in Qt Application Manager
- Run on many platforms
- Specify a custom executable to run
创建模型和图表
通过结构图和行为图创建通用建模语言(UML)风格的模型,为系统提供不同的视图。或者,使用文件向导创建带有模板代码的状态图 XML(SCXML)文件,并使用 SCXML 编辑器进行编辑。
- Create UML-style models
- Create class diagrams
- Create component diagrams
- Create package diagrams
- Create state charts
调试
使用调试器在应用程序运行时检查其状态。
- 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 设计用户界面。Qt Creator 集成了一个可视化编辑器Qt Widgets Designer ,用于在Design 模式下设计基于 widget 的用户界面。对于Qt Quick 用户界面,请使用单独的可视化编辑器、 Qt Design Studio或Edit 模式。
- Create pixmaps from SVG images
- Preview Qt Quick UIs on devices
- Preview a QML file on desktop
- Run QML files
- View images
为设备开发
在计算机上安装为目标嵌入式或移动平台构建应用程序的工具链,并使用Qt Online Installer 安装为该平台构建的 Qt XML 库。然后添加一个包含工具链和设备架构 Qt 版本的工具包。如有可能,Qt Online Installer 会为您创建合适的工具包。将设备连接到计算机,在上面运行、调试和分析应用程序。
安卓
安装Qt for Android和 Android 工具,并将 Android 设备连接到计算机。
- Create an Android Virtual Device (AVD)
- Debug on Android devices
- Manage AVDs
- Manage Android NDK packages
- Manage Android SDK packages
- Set up Android development environment
Bare Metal
使用 GDB 或硬件调试器,在远程 Linux 设备插件不支持的小型 Linux 设备上运行和调试应用程序。
- Add Bare Metal devices
- Set up EBlink
- Set up J-Link
- Set up OpenOCD
- Set up St-Link
- Set up the uVision IDE
Boot to Qt
在设备上运行、调试和分析应用程序 Boot to Qt设备上运行和分析应用程序。
Docker
从Docker 映像创建Docker 设备,并使用它们来构建、运行和调试应用程序。
- Add Docker devices
- Build for and run on Docker devices
- Build on Docker devices
- Set preferences for Docker devices
iOS
安装Qt for iOS和 Xcode,并将 iOS 设备连接到电脑。
微控制器
安装 Qt for MCUs将微控制器连接到计算机。
QNX Neutrino
安装Qt for QNX,并将 QNX Neutrino 设备连接到电脑。
- Add a QNX Neutrino device
- Create kits for QNX Neutrino devices
- Debug remotely with GDB
- Run on QNX devices
远程 Linux
为通用 Linux 设备构建应用程序的工具链添加工具包,并将设备连接到计算机。
- Add remote Linux devices
- Build applications on remote Linux devices
- Configure SSH connections
- Connect remote Linux devices
- Debug remotely with GDB
- Generate SSH keys
- Manage device processes
- Run on remote Linux devices
SDK
管理用于不同平台应用程序开发的 SDK。
- Add MCU SDKs
- Create kits for QNX Neutrino devices
- Manage Android NDK packages
- Manage Android SDK packages
- Manage Windows App SDK packages
VxWorks
为 VxWorks 构建Qt,并创建 VxWorks 构建和运行工具包。
WebAssembly
安装Qt for WebAssembly,为网络构建应用程序并在网络浏览器中运行。
编辑代码
代码编辑器为编辑 C++ 和 QML 代码提供了有用的功能,如语义高亮显示、检查代码语法、代码补全和快速修复。其中一些功能也适用于其他编程语言,如 Python,它的语言服务器可向集成开发环境提供有关代码的信息。
- 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
- 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
配置编辑器
通过更改字体、颜色、高亮显示和缩进来配置代码和文本编辑器,以满足您的特定需求。
- Add code snippets to the auto-complete menu
- Beautify source code
- Change editor colors
- Change text encoding
- Configure C++ code model
- Edit MIME types
- Edit like in Vim
- Select line ending style
- Specify code style
管理语言服务器
配置Qt Creator 默认添加的语言服务器或添加更多语言服务器。
- Add a Java language server
- Add generic language servers
- Configure Python language servers
- Configure QML Language Server
- Configure language servers for projects
- Inspect language clients
搜索
使用增量搜索和高级搜索在当前打开的项目或文件系统中进行搜索,或使用定位器浏览项目、文件、类、函数、文档和文件系统。
- Find symbols
- Navigate with locator
- Rename symbols
- Search and replace using a regular expression
- Search in current file
- Search in projects or file systems
- Turn on Silver Searcher
管理套件
Qt Creator 将构建和运行特定设置作为工具包分组,可使跨平台开发更轻松。每个工具包由一组值组成,这些值定义了一个环境,如要使用的设备、工具链、Qt 版本和调试器命令。
- Activate kits for a project
- Add Bare Metal devices
- Add CMake tools
- Add Nim compilers
- Add Qt versions
- Add compilers
- Add custom compilers
- Add debuggers
- Add kits
- Create kits for QNX Neutrino devices
- Manage MCU Kits
- Open projects
管理项目
创建用于开发应用程序和库的项目。然后配置项目,以便在目标平台上构建和运行应用程序。
- Add libraries to CMake projects
- Configure projects for building
- Configure projects for running
- Create vcpkg manifest files
- Develop Qt for Python applications
- Edit environment settings
- Enable debugging
- Import an existing project
- Open projects
- Run Python applications
- Specify the environment for projects
- Use Qt Creator variables
创建项目
使用预设向导创建项目或添加自定义向导。还可以从版本控制系统导入项目。
- Add libraries to qmake projects
- Add subprojects to projects
- Add wizards
- Create Nimble projects
- Create Qt Quick Applications
- Create Qt Quick UI Prototypes
- Create VCS repositories for new projects
- Select the build system
- Use project wizards
添加文件
为项目添加文件。
- Add a license header template for C++ code
- Add translation files
- Add wizards
- Create C++ classes
- Create OpenGL fragment and vertex shaders
- Create files
- Create resource files
- Set C++ file naming preferences
配置项目
更改安装程序和项目向导创建的默认配置。
- Activate kits for a project
- Apply filters before scanning for tests
- Configure C++ code model
- Configure language servers for projects
- Create VCS repositories for new projects
- 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 clangd settings
- Specify dependencies
- Specify editor settings
- Specify project contents
- Specify settings for quick fixes
阅读文档
Qt Creator 集成了您安装的 Qt 版本的参考文档。您还可以添加其他来源的文档。
- Add bookmarks to help pages
- Add external documentation
- Detach the help window
- Filter documentation
- Find information in Qt documentation
- Get help
- Read CMake documentation
- Search from documentation
- Select the help start page
测试
创建和运行基于代码的测试,并构建基于系统的测试。基于代码的测试为特定的测试框架提供了特殊的处理方法,与底层代码模型或专门的解析器紧密相连。基于构建系统的测试独立于任何测试框架。它直接从底层构建系统获取信息,并使用这些信息甚至构建系统来执行相应的测试。
- 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
使用 Git
Git是一种快速的分散式版本控制系统,适用于 Windows、Linux 和 macOS。您可以在使用 Git 的项目中使用Gerrit 代码审查工具。
- Commit your first change
- Create VCS repositories for new projects
- Git Tools
- Initialize Git repositories
- Set up version control systems
- Use Git for Windows
- Use Git with Subversion
- Use common VCS functions
当前文件
当前项目
本地存储库
- Apply patches
- Interactive rebase
- git am
- git branch
- git clean
- git commit
- git diff
- git log
- git merge
- git reflog
- git reset
- git stash
- git status
承诺
远程存储库
使用Qt Creator
使用Qt Creator 的基本功能和预装插件。安装更多插件并配置外部工具以供使用。
- Collect usage statistics
- Contact Qt
- Enable and disable plugins
- Inspect internal logs
- Install extensions
- Install plugins
- Load extensions
- Manage extensions
- Manage sessions
- Record screens
- Reset Qt Creator settings
- Run Qt Creator from the command line
- Set up version control systems
- Turn on crash reports
- Use Qt Linguist
- Use common VCS functions
- Use external text editors
- Use external tools
使用用户界面
浏览用户界面或更改其外观和行为。
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.