vscode+qt开发环境配置

vscode+qt开发环境配置

vscode + qt 实现代码提示 i3两外两个桌面 打开qt的 ui设计 designer 和文档 assiant 实现高效率开发
这个方法首先需要用qtcreat创建好项目
注:本文适用linux系统用户,windwos用户自行根据配置改动

.vscode 文件夹放四个文件

  1. c_cpp_properties.json 代码提示
  2. tasks.json 编译配置
  3. build.sh 编译脚本 配合task.json使用
  4. launch.json F5 运行代码

代码提示

需要提前装好插件 C++ Intellisense(插件商店搜c++)

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/lib/x86_64-linux-gnu/**", //qt动态库路径 qt版本不同 名字有些许差异 自动更改
                "/usr/include/x86_64-linux-gnu/qt5/**" //qt动态库路径 qt版本不同 名字有些许差异 自动更改
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

编译配置

vscode 编译快捷键 ctrl+shift+b

也可使用shell手动编译
toolkit cmake项目: cmake make
toolkit qmake项目: qmake make

效果相同,快捷键需要配置下方文件

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "qmake",
            "type": "shell",
            "command": "sh",
            "args": [
                "${workspaceRoot}/.vscode/build.sh",
            ],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

build.sh

qmake   #qt配置的cmake的话 这个地方改成cmake
make

运行配置

下方配置 适合习惯用快捷键 F5 调试的用户,我更习惯用terminal直接运行可执行文件

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/a.out", //根据生成的执行文件名自行更改
            "args": [
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

其他

我的习惯

生成makefile : qmake 或者 cmake
编译: make
ui设计: 单独打开一个i3工作区放ui设计界面,打开终端(win/super+enter), designer xxx.ui
单开一个工作区放qt文档:win/super+d assistant

本人习惯用终端编译运行,所以对我来说最有用的是代码提示配置文件 c_cpp_properties.json

我这里生成好了一个.vscode文件,直接放到qt项目,改吧改吧就能用了:git clone https://gitee.com/dspure/vscode-qt.git

  • 2
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值