一、QT相关

1、环境设置相关

2、安装插件:

在CURSOR中安装以下插件:

C/C++插件:这是必需的,用于支持C/C++语言开发。
Qt Configure:用于配置Qt环境。
Qt Tools:提供Qt相关的工具支持。
CMake:如果你使用的是Qt6或更高版本,需要使用CMake而不是qmake。
CMake Tools:辅助CMake构建的工具。

3、配置C/C++插件:

使用快捷键 Ctrl+Shift+P 打开命令面板,输入 C++,选择编辑配置.

c_cpp_properties.json文件如下:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Qt/Qt5.12.12/5.12.12/mingw73_64/include",
                "C:/Qt/Qt5.12.12/5.12.12/mingw73_64/include/QtWidgets"
                
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

4、新建Qt项目

千万记得去掉debug和release的shadow.(去掉之后编译一下才生效)

二、CURSOR相关

1、tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "qmake-debug",
            "type": "shell",
            "command": "qmake",
            "args": [
                "C:/Users/Administrator/Documents/untitled16/untitled16.pro",
                "CONFIG+=debug"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": []
        },
        {
            "label": "qmake-release",
            "type": "shell",
            "command": "qmake",
            "args": [
                "C:/Users/Administrator/Documents/untitled16/untitled16.pro",
                "CONFIG+=release"
            ],
            "group": "build",
            "problemMatcher": []
        },
        {
            "label": "make-debug",
            "type": "shell",
            "command": "mingw32-make",
            "dependsOn": "qmake-debug",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [
                "$gcc"
            ]
        },
        {
            "label": "make-release",
            "type": "shell",
            "command": "mingw32-make",
            "dependsOn": "qmake-release",
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

2、c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Qt/Qt5.12.12/5.12.12/mingw73_64/include",
                "C:/Qt/Qt5.12.12/5.12.12/mingw73_64/include/QtWidgets"
                
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22000.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

这样,就可以run task,先qmake,后make

注意,生成的release版本的exe文件,需要windeployqt 打包一下,否则执行的时候会提示入口错误。

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐