6 ms·
Using Visual Studio Code for Qt Applications
- tpush 7y agoI'd recommend using clangd together with the vscode-clangd extension instead of VSCode's "official" C/C++ extension. Properly set up with a compile_commands.json and its pretty much better than any C/C++ IDE I've ever used.
- frabert 7y agoccls works even better than clangd, in my experience.
- satysin 7y agoInteresting. I have used VSCode on Mac for C++ but it has been a royal pain in the ass recently with lldb-mi issues related to Catalina. If you don't mind sharing I am very interested in your setup.
- tpush 7y agoSure! 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.
- pfranz 7y agoIn case you (or someone else reading this) didn't eventually find a workaround, here's how I was able to get lldb-mi to work in Catalina: https://github.com/microsoft/vscode-cpptools/issues/3829#issuecomment-578454043 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#issuecomment-599222739 https://github.com/microsoft/vscode-cpptools/issues/3829#iss...
- rvanlaar 7y agoCould you explain what is better? And how to properly set up compile_commands.json? It seems I struggled with getting `make` to work with VScode.
- zamalek 7y agoDebugging for one. You have to use a C++ debugger alongside Rust, and the lldb debugger is immensely superior (especially where structs are concerned in locals/watch). I strongly recommend you have a look at vcpkg for getting tooling such as make and gcc installed.
- chenzhekl 7y agoI would like to recommend the official C++ extension + CMake Tools. This combination provides great IDE-like experiences.
- zerr 7y agoIs it that hard for addons to implement proper settings GUI dialogs in vscode? Editing json files by hand is step backwards, especially when this comes from the company which also produces (real) Visual Studio.
- tpush 7y agoWhat settings are you referring to? VSCode's settings (both main and extensions) have a GUI view. The compile_commands.json is always generated and not meant to be edited at all.
- zerr 7y agoSettings of particular extensions, e.g. Golang's. When something is explained (e.g how to add build targets) it always goes to editing some json files.
- frosted-flakes 7y agoThe settings GUI in VS Code was only added in the past year or so. So it's likely that a lot of documentation hasn't been updated to mention this. 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.
- AbuAssar 7y agowhat advantages does vscode add for c++ development over current IDEs and editors?
- reyqn 7y agoI guess if you're used to vscode there is that.
- tinybug 7y agoIt's simple, light weight, a lot of cool extensions. I use vscode for developing nodejs, python, ffmpeg, Qt, frontend...it's my all in one IDE.
- zabana 7y agoHow do you develop ffmpeg what do you mean ? What kind of projects can one create ? Do you mind sharing resources ? You got me interested ^^
- tinybug 7y agoI develop some filters to ffmpeg or read ffmpeg codes in vscode. Build by makefile and then debug in ffmpeg.
- Yizahi 7y agoHow exactly it is lightweight when it carries a copy of Chrome browser in the background? Jut at idle with no files opened it uses 600 Mb of memory. PS: it is a nice software which I also use extensively, but Electron is an abomination, Flash of 21 century.
- irishcoffee 7y agoQtcreator is leaps and bounds ahead of vs
- slezyr 7y agoYeah, also the only IDE that can open and index Chromium sources(about 40k files).
- pfranz 7y agoA few weeks ago I was reaching for VScode + Qt because I normally do a bunch of small one-offs. My go-to is mostly command line (vim and shell scripts for building or Makefiles or eventually cmake if things get "heavy")--which means I'm very excited about avoiding qmake in favor of cmake. I find most IDEs unbearably slow and heavy, but I really like Visual Studio's debugger (with multiple languages). 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.
- Alir3z4 7y agoThanks for this, I'm sure many would give it a try and will like the idea of having the possiblity and easier selection when working with their favorite IDE or editor when working with Qt. 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 ?
- Naac 7y agoYou're not the first person to mention QtCreator for c/c++ projects ( not even using QT ). Can you elaborate about what you like about QtCreator over other c/c++ IDEs?
- GnarfGnarf 7y agoI use Visual Studio 2017 to develop a Qt application on Windows. I use Qt Creator (QtC) for same app on macOS. I love Qt, am delighted to have converted from Win32. 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.
- jcelerier 7y agoFun, I have exactly the opposite experience re. VS and Qt Creator - VS sometimes takes, like 15 minutes to start a debug session on a large project while QtC can get to work in the same time that it would take gdb to start. And that's without counting the clang-based code model, all the niceties under the locator (ctrl-k), etc etc > 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 !
- TravHatesMe 7y agoNot sure if this applies to Qt, but VS2019/netcore has made tremendous strides with its tiered compilation.
- GnarfGnarf 7y agoSorry, I meant keyboard shortcut macros (Ctrl M, R in VS 2017).
- Vysero 7y agoIs there a reason I wouldn't just use creator? Does VS offer me something creator can not?
- jhasse 7y agoTabs
- jcelerier 7y agoQt Creator has vertical tabs ("Opened documents" panel) which is way superior as soon as you have more than 3 files open. It's also pretty useless since you can just <ctrl-k> <first few letters> <enter> or <ctrl-tab> to switch
- wwright 7y agoIt has a better extension ecosystem by a wide, wide margin. Some of the benefits that can bring from my personal experience: - 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 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.
- jakearmitage 7y agoI love Qt Creator, but the lack of tabs drives me nuts. The interface is so unfamiliar that I just can't use it. I use it to debug, to build interfaces, to compile, etc... but to code, I just use Sublime/VS Code/Atom/whatever.
- slezyr 7y agoThat's funny because I prefer "Open Documents" dock in QtCreator to the tabs. It's hard for me to switch between files because I can just see 7-8 tabs without scrolling and in the dock I might have 20 files with longer names.
- xrd 7y agoIs anyone here using gitlab with a runner to build QT applications upon commit? I've got a friend who needs this and he is only using QTCreator but it seems like building inside a docker container should be possible. I guess I'm asking: can all the things discussed here be done from command line instead of inside the editor and if so, how do you determine those commands?
- detaro 7y agoSure, you don't need an IDE to build a Qt app. 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.
- ucosty 7y agoI have a project that has this same workflow, in my gitlab-ci file I just run qmake followed by make. I have a custom container which contains the QT library and build tools.
- xrd 7y agoAre any of you available for a consulting project? If so, can you email me at the email in my profile?
- wwright 7y agoI've led adoption on that exact setup at work. You can definitely do it, but I have nothing but bad things to say about Qmake. It's poorly documented, inscrutable, and a huge PITA. Switch to any other build system if you can. That said, automating the builds in GitLab CI was worth it 1000x over.
- irishcoffee 7y agoIf you’re fighting qmake there is a very good chance you’re fighting the wrong problem. Is your build a complicated mess? (It shouldn’t be) Do you have a complicated multi platform mess (it shouldn’t be complicated) I would be happy to take a look at your build.