Problem to solve
@tonka3000 About what you said in this reply,
For dev scenario it would be better to inject the PATH variable automatically into launch.json. There is a dedicated variable name environment for that. That way it would be automatically done for you without any copy of files.
If we use this method, we have to manually prepend those bin directory into environment variable PATH. Then, if we change another version of Qt, we also need to modify the value of that. It's very cumbersome.
Proposal
Here's my advise. After Qt-Tools found the Qt Kits, it can provides some Command Substitutions just like CMake-Tools does. After that, we can prepend PATH with the bin directory of Qt that variable in launch.json. Moreover, we may use them in program of tasks.json.
Further details
Provide some Command Substitutions like:
qt.getQtPrefixPath: "C:\Qt\6.2.0\msvc2019"
qt.getDeployqtPath: "C:\Qt\6.2.0\msvc2019\bin\windeployqt.exe"
qt.getQmakePath: "C:\Qt\6.2.0\msvc2019\bin\qmake.exe"
qt.getUicPath: "C:\Qt\6.2.0\msvc2019\bin\uic.exe"
qt.getMocPath: "C:\Qt\6.2.0\msvc2019\bin\moc.exe"
Case 1: Prepend the bin directory to environment variable PATH:
{
"version": "0.2.0",
"configurations": [
{
"name": "(CMake) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"cwd": "${command:cmake.launchTargetDirectory}",
"stopAtEntry": false,
"environment": [
{
"name": "PATH",
"value": "${command:qt.getQtPrefixPath}/bin;${env:PATH}"
}
],
"console": "externalTerminal"
}
]
}
Case 2: Use it in program of tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Qt Deploy executable",
"type": "shell",
"command": "${command:qt.getDeployqtPath}",
"args": [
"${command:cmake.launchTargetPath}"
"--verbose 2",
"--no-translations"
],
"problemMatcher": []
}
]
}
Problem to solve
@tonka3000 About what you said in this reply,
If we use this method, we have to manually prepend those
bindirectory into environment variablePATH. Then, if we change another version of Qt, we also need to modify the value of that. It's very cumbersome.Proposal
Here's my advise. After Qt-Tools found the Qt Kits, it can provides some Command Substitutions just like CMake-Tools does. After that, we can prepend
PATHwith thebindirectory of Qt that variable inlaunch.json. Moreover, we may use them inprogramoftasks.json.Further details
Provide some Command Substitutions like:
qt.getQtPrefixPath: "C:\Qt\6.2.0\msvc2019"qt.getDeployqtPath: "C:\Qt\6.2.0\msvc2019\bin\windeployqt.exe"qt.getQmakePath: "C:\Qt\6.2.0\msvc2019\bin\qmake.exe"qt.getUicPath: "C:\Qt\6.2.0\msvc2019\bin\uic.exe"qt.getMocPath: "C:\Qt\6.2.0\msvc2019\bin\moc.exe"Case 1: Prepend the
bindirectory to environment variablePATH:{ "version": "0.2.0", "configurations": [ { "name": "(CMake) Launch", "type": "cppvsdbg", "request": "launch", "program": "${command:cmake.launchTargetPath}", "args": [], "cwd": "${command:cmake.launchTargetDirectory}", "stopAtEntry": false, "environment": [ { "name": "PATH", "value": "${command:qt.getQtPrefixPath}/bin;${env:PATH}" } ], "console": "externalTerminal" } ] }Case 2: Use it in
programoftasks.json:{ "version": "2.0.0", "tasks": [ { "label": "Qt Deploy executable", "type": "shell", "command": "${command:qt.getDeployqtPath}", "args": [ "${command:cmake.launchTargetPath}" "--verbose 2", "--no-translations" ], "problemMatcher": [] } ] }