Using Visual Studio Code for Qt Applications
kdab.com
kdab.com
Having said that, I will never leave QtCreator for VS Code, not that is not good, but QtCreator feels much solid and integrated than any other IDE when working with Qt/C++ or many C/C++ code bases out there, in matter of fact, QtCreator is my go to when doing c/c++.
I've tried CLion but I don't think will use that either.
Need to mention is so damn light ?
I strongly recommend you have a look at vcpkg for getting tooling such as make and gcc installed.
Even so, I prefer editing the JSON files directly. I can easily see what's changed from the default, add comments, and make groups of settings.
If you don't mind sharing I am very interested in your setup.
I use CMake for all my projects, and passing "-D CMAKE_EXPORT_COMPILE_COMMANDS=ON" generates the compile_commands.json for clangd. I create a symlink to it in the main project folder so clangd can find it.
Clangd embeds clang-format and clang-tidy, so given appropriate configuration files formatting in VSCode just works with no extra extensions but vscode-clangd.
For debugging, I use CodeLLDB. Haven't had any problems with it so far, everything seems to work fine. Debug console works etc.
https://github.com/microsoft/vscode-cpptools/issues/3829#iss...
I also had the library issue mentioned here and copied the file the same way to fix that: https://github.com/microsoft/vscode-cpptools/issues/3829#iss...
Sorry but VS still feels as solid as a tank, Qt Creator is less responsive to my needs.
- 'asserts' in QtC bring the debug session to a grinding halt. I can't step over like I can in VS.
- Where can I define macros in QtC?
- In debug mode, QtC is unable to display certain types of variables, way too often.
- I have fiddled for days with the .PRO file, read all the StackOveflow posts, and I still can't suppress reams of pedantic warnings.
- QtC just gives the impression of a rudimentary attempt at VS, like things are about to fall apart at any moment. To a programmer accustomed to VS, there always seems to be something missing, and I don't mean just different keyboard shortcuts. QtC has a long way to go.
Still, it's better than a text editor and the command line.
> Where can I define macros in QtC?
the IDE is imho not the place to do that. Just use CMake and target_compile_definitions(my_target PRIVATE MY_MACRO=123)
> - In debug mode, QtC is unable to display certain types of variables, way too often.
very strange, but then I mostly use it on Linux with gdb / lldb, maybe the cdb integration is less good.
> - I have fiddled for days with the .PRO file, read all the StackOveflow posts, and I still can't suppress reams of pedantic warnings
If CONFIG += warn_off in your .pro (switch to cmake !!!) does not work please file bugs !
I hear great things about QtCreator, but for me it's more about not wanting to invest in yet another large application for things I don't do every day.
If you set it up using cmake, it's like any other app: cmake, make, done. (cmake has support for handling the Qt specific bits for you)
If you're using Qt's qmake, which is likely if they just started with QtCreator, you call qmake and then make to build.
In both cases I'd refer you to Qt's documentation for details, but QtCreators project configuration UI and build log also shows you which commands it is running.
That said, automating the builds in GitLab CI was worth it 1000x over.
I would be happy to take a look at your build.
- qmake doesn't support true dependencies between subprojects (ie, if I ask it to build a/b/c, it can't know that a/b/c depends on d/e/f)
- qmake's support for integrating additional compilers is inscrutable and again, has terrible issues with parallelism and dependencies
- the way it is backed by make is prone to incremental build issues
I have qt kits to build for 4 different platforms and 3 different build toolchains. It was very easy to set up, and flipping between kits either in creator or in a terminal takes mere seconds.
I have never experienced your 3rd point.
By “additional compilers,” I mean adding additional metacompilers, other languages, and so on. There is QMAKE_EXTRA_COMPILERS, but I can’t figure out how to get it to properly integrate with the dependency graph for the life of me.
Have you ever had to resort to “make distclean” to get a clean compile?
For your second point: https://ortogonal.github.io/qmake-extra-compiler/ I have never used this but it looks straightforward enough.
I have never had to use make distclean. I use make clean && qmake && make sometimes.
I'm not a fan of qmake but this works just fine with it.
Given I have this layout:
bin/bin.pro # specify bin/bar/ as subfolder
bin/bar/bar.c
bin/bar/bah.h
bin/bar/bar.pro
lib/lib.pro # specify lib/foo/ as subfolder
lib/foo/foo.c
lib/foo/foo.h
lib/foo/foo.pro
project.pro # specify bin/ and lib/ as subfolders
And I have a fresh checkout, how do I compile "bin/bar" and all of its dependencies automatically? I want to run ONLY "bin/bar". I don't want to compile the entire repo. I don't want to have to investigate "bin/bar" and learn all of its transitive dependencies. I just want to run "bin/bar".Honest to god, I have wanted this for over a year and it does not seem possible.
How they do it while using Electron? No idea.
Edit: My bad, apparently I didn't count all processes.
Launching it with no files open, the total private+shared memory adds up to ~300 MB. Screenshot of macOS Activity Monitor:
This memory usage is roughly the same on Windows 10 Task Manager:
In contrast, the so-called "heavier" classic Visual Studio 2019 v16.5 (devenv.exe) with no files open, Task Manager stats shows it using less than ~200 MB.
I think some folks get the impression VSCode is "lightweight" because the GUI/UI is lightweight. VSCode is less "busy" looking... less menu options, no ribbon with icons, less multi-panels of properties, etc. VSCode's GUI looks more like a bare-bones "text editor" than an IDE.
You got me interested ^^
That's been my experience with watching stubborn fellow co-workers struggling with it while doing python development. On paper, it has all the features and whistles of course, so therefore it's the "best IDE".
Code completion, type-annotation, debugging, virtualenv, built-in linting, docker support, etc. But then when you use them, it's a virtual catastrophe of configs, random "does it work, no, try the config again, does it work now? Yes No?" And so it continues, for an hour. Meanwhile, a python IDE like PyCharm just works without hassle.
- Using the same editor setup for tons of different environments (Python, C/C++, Rust, JavaScript, TypeScript, Java, Go, and more are all very well supported)
- The VS Code remote editing extensions are fantastic: https://code.visualstudio.com/docs/remote/remote-overview
- There are live collaboration extensions that let you pair program with other devs over the internet, with really good responsiveness
- The remote extension also lets you specify a dockerfile/image ref + plugin configuration in your repository, which can then be used for your editing. This effectively gives you transparent, Git-based, immutable development environments. This can be a big productivity boost.
I've also found it pretty easy for most people to pick up and use, and it's also fairly lightweight and reasonable IME.