# ide-qt-support **Repository Path**: openkylin/ide-qt-support ## Basic Information - **Project Name**: ide-qt-support - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2024-06-07 - **Last Updated**: 2026-02-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Qt 支持 [Readme in English](#qt-support) ![](https://gitee.com/openkylin/ide-qt-support/blob/master/res/demo.gif) Qt Support 扩展,支持创建/导入基于 CMake 的 Qt 项目,添加常见的 Qt 组件,如资源文件,翻译文件,类,设计器表单类等,`Shift+F1` 快捷键查看 Qt 文档,调用 Qt Designer,Qt Linguist 等工具。该扩展依赖于另外几个扩展: - CMake Tools `ms-vscode.cmake-tools` - Clangd `kylinideteam.vscode-clangd` - Native Debug `kylinideteam.debug` - CMake Intellisence `kylinideteam.cmake-intellisence` **注意:** 这些扩展仅仅在 Windows 上和 Linux 上测试过。 ## 注意事项 ### Qt 的安装位置: `qt-support.qtInstallDirectories` 扩展启动时会扫描 Qt 的默认安装位置,如果没有发现您安装的 Qt 时,可以设置该选项来指定 Qt 的安装位置。该位置需要设置为 Qt 的安装根目录,比如:`D:\apps\Qt`, `/home/user/.Qt` 等。 ### 依赖的软件 1. `ninja-build`: 只有使用 ninja generator, CMake 才可以在所有的平台上都生成 clangd 需要的 `compile_commands.json` 文件,所以请首先安装该软件。 2. 关于 Qt 文档:如果您的 Qt 是通过 Qt online installer 安装的,那么大概率文档已经安装。如果你在 linux 平台上,并且你使用的 Qt 是通过系统包管理器安装的。那么一般需要您额外安装 Qt 文档。 + 基于 apt 包管理器的系统:`sudo apt install qt5-doc qt5-doc-html` + 基于 yum/dnf 包管理器的系统:`sudo dnf install qt5-qtbase-doc qt5-qtdoc` 3. 其它软件 + 基于 apt 包管理器的系统:`sudo apt install build-essential ninja-build gdb cmake clangd qt5-default qttools5-dev-tools qttools5-dev qt5-qmake` + 基于 yum/dnf 包管理器的系统:`sudo dnf install gcc gcc-c++ make-devel ninja-build gdb cmake clang-tools-extra qt5-devel` 4. Windows 上,Qt 一般通过 online installer 安装。另外请自行安装 `ninja-build cmake clangd` 等工具, ### 关于 Qt Kit 扫描到 Qt 后,会在系统的缓存中生成 qt-kits.json 文件。CMake Tools 工具会读取该配置文件,并在 CMake Tools 扩展的 Kit 列表中显示,方便选择不同的 Qt 版本。该扩展提供的 Qt Kit,均以 `[Qt Support]` 开头。同时,该扩展在状态栏的左侧也提供了用于选择 Qt Kit 的按钮。 ### 关于调试和运行 由于 CMake Tools 的调试功能依赖于 C/Cpp Tools,该扩展隐藏了 CMake Tools 的调试和运行功能,在状态栏提供了自己的调试和运行按钮。可通过状态栏的调试和运行按钮来调试和运行 Qt 程序。本扩展提供的调试和运行按钮的描述文本中有 `(Qt Support)` 字样。 调试插件目前使用的 `kylinideteam.debug`,暂不支持 Windows 上的 MSVC 编译器以及 mingw。您也可以直接到该插件的[仓库](https://gitee.com/openKylin/native-debug)提问题或者做贡献: ## 特性 该扩展提供以下特性 1. Qt 项目创建 2. 导入基于 CMake 的 Qt 项目 3. 添加 Qt 项目文件 - Designer Form Class - Designer Form - C++ class - Translation - Resource 4. `Shift + F1` 快捷键查看 Qt 的文档 5. qrc 资源编辑器 6. 使用 Qt Designer 打开 ui 文件 7. 使用 Qt Linguist 打开 ts 文件 8. 使用 Qt Creator 打开项目 9. 使用 Visual Studio 打开项目 ### 创建和导入项目 可以通过以下四种方式使用创建/导入项目的功能: 1. 在命令面板中搜索命令 `Qt Support: Create Qt Project...` 2. 在没有打开文件夹的情况下,按下 `Ctrl + Shift + E` 打开资源管理器,在欢迎视图中点击 `Create Qt Project` 按钮 3. 在已经打开文件夹的情况下,资源管理器的右键菜单中有 `Create Qt Project` 选项 4. 点击文件菜单 > 新建文件,在出现的 Quick Pick 中选择 `创建 Qt 项目` ### 添加 Qt 组件 在已经打开 Qt 项目的情况下,按下快捷键 `Ctrl + shift + E`,在 Kylin-IDE 的资源管理器中点击鼠标右键,弹出的右键菜单中有 `为 Qt 项目添加新文件` 的上下文菜单。选择相应的子菜单就可以向项目中添加相关类型的文件。 ### `Shift + F1` 快捷键查看 Qt 的文档 当选择 Qt Kit 之后,打开 C++ 文件,将光标放置于想要查看文档的函数,类,方法名上面,按下 `Shift + F1` 快捷键,就会显示对应符号的文档。体验类似于 Qt Creator 的 F1 查看文档功能。如果该功能不可用,请尝试以下方法: 1. 鼠标放置在函数名上之后,按下 `Ctrl + Shift + p` 打开命令面板,搜索命令 `Qt Support: Show symbol documentation under cursor`, 并执行 2. 如果上面的方法可行,请检查快捷键配置,查看是否时快捷键冲突,并设置为想要的快捷键 ### Qt 资源编辑器 该扩展提供了一个 Qt 资源编辑器,可以方便的编辑 Qt 的资源文件。当点击 .qrc 文件时,Kylin-IDE 默认会使用该扩展提供的 Qt 资源编辑器来打开 .qrc 文件。 ### 打开外部工具 可以调用 Qt Designer 打开 .ui 文件,调用 Qt Linguist 打开 .ts 文件。有几种方式可以调用相关的命令: - 在 Kylin-IDE 资源管理器中鼠标右键点击相应类型的文件,在右键菜单中会有相关的命令 - 当 .ui / .ts 文件处于打开状态时,在编辑器的标题栏中会有相关的按钮 - 当 .ts 文件处于打开状态时,在编辑器的上下文菜单中也会有相关的按钮 - 点击 .ui 文件后,会显示一个 webview,webview 中有一个按钮,点击按钮可以打开 Qt Designer ### 使用其它 ide 打开项目 可以使用 Qt Creator 和 Visual Studio (仅支持 Windows)打开项目,使用 Visual Studio 打开项目时,会自动生成 Visual Studio 所需的 CMakeSettings.json 文件,可以直接在 Visual Studio 中直接运行,调试基于 CMake 的 Qt 应用程序。 按下快捷键 `Ctrl + shift + p`打开命令面板,搜索关键字 `Qt Support: Open project in`,可以看到相关的命令。 ## 问题反馈 如果遇到任何问题,请前往 [Gitee](https://gitee.com/openKylin/ide-qt-support/issues) 反馈问题。 # Qt Support [中文说明](#qt-支持) Qt Support extension, supports creating/importing Qt projects based on CMake, adding common Qt components such as resource files, translation files, classes, designer form classes, etc. Use the Shift + F1 shortcut key to view Qt documentation and invoke tools such as Qt Designer and Qt Linguist. This extension relies on several other extensions: - CMake Tools `ms-vscode.cmake-tools` - Clangd `kylinideteam.vscode-clangd` - Native Debug `kylinideteam.debug` - CMake Intellisense `kylinideteam.cmake-intellisence` **Note**: These extensions have only been tested on Windows and Linux. ## Notes ### Qt Installation Location: `qt-support.qtInstallDirectories` When the extension starts, it scans the default installation location of Qt. If it doesn't detect your installed Qt, you can set this option to specify the installation location of Qt. This location needs to be set to the root directory of Qt's installation, such as: D:\apps\Qt, /home/user/.Qt, etc. ### Dependent software + `ninja-build`: Only when using the ninja generator can CMake generate the compile_commands.json file required by clangd on all platforms. So, please install this software first. + Qt documentation: If your Qt is installed through the Qt online installer, the documentation is likely already installed. If you are on the Linux platform and your Qt is installed through the system package manager. Then, generally, you need to install Qt documentation additionally. + Systems based on the apt package manager: `sudo apt install qt5-doc qt5-doc-html` + Systems based on the yum/dnf package manager: `sudo dnf install qt5-qtbase-doc qt5-qtdoc` + Other software + Systems based on the apt package manager: `sudo apt install build-essential ninja-build gdb cmake clangd qt5-default qttools5-dev-tools qttools5-dev qt5-qmake` + Systems based on the yum/dnf package manager: `sudo dnf install gcc gcc-c++ make-devel ninja-build gdb cmake clang-tools-extra qt5-devel` + On Windows, Qt is generally installed through the online installer. Additionally, please install tools such as ninja-build cmake clangd yourself. ### About Qt Kit After scanning Qt, a qt-kits.json file is generated in the system cache. The CMake Tools tool reads this configuration file and displays it in the Kit list of the CMake Tools extension for convenient selection of different Qt versions. The Qt Kit provided by this extension starts with [Qt Support]. Meanwhile, this extension also provides a button for selecting Qt Kit on the left side of the status bar. ### About Debugging and Running Since the debugging function of CMake Tools relies on C/Cpp Tools, this extension hides the debugging and running functions of CMake Tools and provides its own debugging and running buttons in the status bar. You can debug and run Qt programs through the debugging and running buttons in the status bar. The description text of the debugging and running buttons provided by this extension contains (Qt Support). The debugging extension currently uses kylinideteam.debug, and temporarily does not support the MSVC compiler and mingw on Windows. You can also directly raise issues or contribute to this extension at its ![repository](https://gitee.com/openKylin/native-debug) ## Features This extension provides the following features: 1. Qt project creation 2. Importing Qt projects based on CMake 3. Adding Qt project files + Designer Form Class + Designer Form + C++ class + Translation + Resource 4. Use the Shift + F1 shortcut key to view Qt documentation 5. qrc resource editor 6. Open ui files using Qt Designer 7. Open ts files using Qt Linguist 8. Open projects using Qt Creator 9. Open projects using Visual Studio ### Creating and Importing Projects You can use the following four methods to create/import projects: 1. Search for the command `Qt Support: Create Qt Project...` in the command palette. 2. When no folder is open, press `Ctrl + Shift + E` to open the Explorer and click the `Create Qt Project` button in the welcome view. 3. When a folder is already open, there is a `Create Qt Project` option in the right-click menu of the Explorer. 4. Click File menu > New File, and select `Create Qt Project` in the Quick Pick that appears. ### Adding Qt Components When a Qt project is already open, press `Ctrl + shift + E`, right-click in the Kylin-IDE Explorer to bring up the context menu with the option `Add new file to Qt project`. Select the corresponding submenu to add the relevant type of file to the project. ## Use the Shift + F1 shortcut key to view Qt documentation After selecting the Qt Kit, open the C++ file, place the cursor on the function, class, or method name for which you want to view the documentation, and press the Shift + F1 shortcut key, and the documentation of the corresponding symbol will be displayed. The experience is similar to the F1 documentation viewing function of Qt Creator. If this function is not available, please try the following methods: 1. After placing the mouse on the function name, press `Ctrl + Shift + p` to open the command palette, search for the command `Qt Support: Show symbol documentation under cursor`, and execute it. 2. If the above method works, please check the shortcut key configuration to see if there is a shortcut key conflict and set it to the desired shortcut key. ### Qt Resource Editor This extension provides a Qt resource editor, which makes it easy to edit Qt's resource files. When clicking on a .qrc file, Kylin-IDE will by default use the Qt resource editor provided by this extension to open the .qrc file. ### Opening External Tools You can call Qt Designer to open .ui files, and Qt Linguist to open .ts files. There are several ways to call the relevant commands: - Right-click on the corresponding type of file in the Kylin-IDE Explorer, and there will be related commands in the right-click menu. - When a .ui / .ts file is open, there will be related buttons in the title bar of the editor. - When a .ts file is open, there will also be related buttons in the context menu of the editor. - After clicking a .ui file, a webview will be displayed, and there is a button in the webview. Clicking the button will open Qt Designer. ### Opening Projects in Other IDEs Projects can be opened with Qt Creator and Visual Studio (Windows only). When opening projects with Visual Studio, a `CMakeSettings.json` file required by Visual Studio is automatically generated, allowing direct running and debugging of CMake-based Qt applications in Visual Studio. Press `Ctrl + shift + p` to open the command palette and search for `Qt Support: Open project in` to see related commands. ## Feedback If you encounter any problems, please go to [Gitee](https://gitee.com/openKylin/ide-qt-support/issues) to provide feedback.