安装组件选择:
版本5.13。组件:Sources,MinGW 7.3.0 64-bit,带Qt前缀的组件,Developre and Designer Tools里的MinGW 7.3.0 64-bit。
调试:
用Qt生成一个默认工程(基类选择QWidget),把生成的cpp,h,ui(在与工程文件夹并列一个文件夹里)文件都复制一份并放到一个文件夹(例:Test1)里。
打开Qt的终端(Qt 5.13.0 (MinGW 7.3.0 64-Bit)),执行路径改为当前文件夹,执行qmake -project,这时会生成和文件夹同名的pro文件,在这个pro文件里最后加上QT += widgets。
执行qmake,这时会自动生成Makefiel和一些文件。执行make -f Makefile.Debug,会在debug文件夹里生成exe文件,这时执行路径进入debug文件夹,执行windeployqt Test1.exe,自动在文件夹下添加所需的依赖文件。
把工程文件夹加到Vscode,为其添加launch,tasks文件。
launch.json使用C/C++的GDB/LLDB配置,exe用debug版的,gdb使用Mingw64的(自行安装的也可以用)。tasks.json命令使用make -f Makefile.Debug。
可以开始调试了。
编辑ui文件时转到槽会提示找不到ui_xxx.h文件,直接保存即可。
launch.json
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: /fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch","program": "${workspaceFolder}/debug/Test1.exe","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "D:/Data/Computer/Language/C++/Tool/Mingw64/mingw64/bin/gdb.exe","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "Build"}]}
tasks.json
{"version": "2.0.0","tasks": [{"label": "Build",// build任务"type": "shell","command": "make -f Makefile.Debug"}]}