Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Visual studio code with Qt/Qmake? (macOS)

How to use Qt with Visual Studio Code? I have Qt 5.15.1 installed which builds my code for macOS, Android and iOS.

Is it possible to have Visual Studio Code build my Qt application for macOS, Android and iOS like QtCreator does?

Environment:
My developer environment is macOS Catalina.

like image 827
TheWaterProgrammer Avatar asked Dec 05 '25 06:12

TheWaterProgrammer


1 Answers

If you're using cmake, which you should, then all you need to do is configure your cmake project to point to your Qt folder, which basically means setting the project's Qt5_dir env variable to point to your Qt installation.

Here's what you need to do to get Visual Studio Code to work with Qt using Microsoft's CMake Tools extension:

  • Verify that you really have Qt installed,
  • Install Microsoft's CMake Tools extension,
  • Open CMake Tools extension's "Edit CMake Cache (UI)"
    • click on "CMake extension" on vscode's activity bar to open "CMake: project outline",
    • click on the "View and more actions" button (i.e., elipsis on upper right corner of the project outline.
  • Edit CMake's cache to point Qt5_dir to ${QTINSTALLDIR}/5.15.1/gcc_64/lib/cmake/Qt5
  • Rebuild project.

You can achieve the same goal by using cmake-gui to configure your cmake project.

If instead you really want to stick with qmake then it's enough to setup a build task that runs qmake.

like image 53
RAM Avatar answered Dec 08 '25 02:12

RAM