Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up QtCreator (Guide + Scripts) #4934

Open
JohannesLorenz opened this issue Apr 7, 2019 · 12 comments
Open

Setting up QtCreator (Guide + Scripts) #4934

JohannesLorenz opened this issue Apr 7, 2019 · 12 comments

Comments

@JohannesLorenz
Copy link
Contributor

JohannesLorenz commented Apr 7, 2019

Motivation

It's important to have your IDE setup correctly before coding the first line. It will:

  • Make reading/editing code waaayyyyy easier
  • Reduce the code review editorial a lot (especially style issues)

Everyone can use their favourite IDE, but QtCreator is one of the most popular, and it's practical for dealing with Qt code. It's not worth for every programmer to

  • Find out how to create a good project file (for each worktree/branch!)
  • Read our coding conventions and try to reflect them in style files

No one wants to mess around with that for every branch. It's probably also annoying for LMMS beginners to say: "Welcome to LMMS, before you code, please spend 2 hours getting your IDE ready". They might prefer a "Hello, just run generate-project.sh and start coding immediatelly".

That is why we should make it as easy as possible to set this up.

Proposals

  1. How to load a project
    a. One way is to use QtCreator's CMake importer. That usually works flawless, but the file tree can look a bit unordered. QtCreator with CMake
    b. We could also autogenerate project files using a script. Questions:
    1. I wonder what language should be used - should it work on Windows (@justnope) ?
    2. Compiling LMMS requires a few autogenerated headers in the build directory. Should the project file be bound to a configuration (like "build/")?
      QtCreator with project files
  2. How to keep coding conventions?
    a. QtCreator allows importing XML code style files. We should deliver one.
    b. You can use clang-format to re-format existing files ( Add .clang-format and .clang-tidy #4690 ), but you'll rarely need this.

Summary

Maybe something like this?

data/IDE/qt-creator/README.md
data/IDE/qt-creator/generate-project.sh
data/IDE/qt-creator/code-style.xml
@musikBear
Copy link

good beginning/ first issue :+1

@JohannesLorenz JohannesLorenz changed the title Setting up QtCreator Guide Setting up QtCreator (Guide + Scripts) Apr 8, 2019
@tresf
Copy link
Member

tresf commented May 4, 2019

@JohannesLorenz can you explain what these auto-config scripts are for and an example of another project that use scripts for setup?

For example, I'm familiar with the ability for Java projects with IntelliJ IDEA to run tasks at start, but when the environment is missing stuff, it's not really much better than just placing it into the build logic (e.g. cmake, or in the case of Java, maven or ant.).

I think setting up the code editor is not a two-hour task, but rather a 2-minute task. I feel the gap is mostly in formatting (as we've identified in other bug reports) as well as non-IDE aware CMakeLists but even then the learning curve is just lack of familiarity. Working to improve this is tricky. For example, Qt5 is provided with Qt Creator, but we try to find it anyway. I've started to address the Qt5 detection scenario here (superseded -- in part -- by MSVC commits to master/work from others) but the general idea is that the project can be complied by CLI or IDE equally and that the assumption of a Qt runtime that's provided by the IDE should be automatic and transparent to the average user looking to hack at a few lines of code.

Using Qt Creator can be summarized with videos that can also save a bunch of time. So far, the only attempts I've seen to do this was done by @curlymorphic. Here are the tutorials:

http://youtu.be/XTWnQPGL9xs
http://youtu.be/3OzGXfm6fqE

What I think is important is that a good idea today is better than a great idea tomorrow. If Qt Creator is to be embraced, put something in the wiki helping others. As people start to use it, it can be improved.

@cubician (renamed or deleted his github apparently) is our official YouTube tutorial maker, perhaps he's interested in making an updated version of @curlymorphic videos.

@JohannesLorenz
Copy link
Contributor Author

(I was mostly referring to the Linux situation, I can't speak for the other OSes)

Initially, you have to run qmake and then patch variables:

  • QT += xml core gui widgets
  • INCLUDES += . build/ build/src /usr/include/lilv-0 and probably more, e.g. rpmalloc
  • DEFINES += ...

This patching is already complicated. Also, when you switch branches (I do multiple times a day), you can

  • either run qmake again, patching all those variables again, wasting 5 minutes
  • try to add new files (new because of the branch switch) into the .pro file (HEADERS+=, SOURCES+=). But if you have 5 or 10 new files, and make typos (was that cpp file now in src/tracks, src/gui or src/gui/widgets?)...

That's why I'm writing a WIP generator script that

  • calls qmake
  • patches QT, INCLUDES, DEFINES for you

More stuff can be done. E.g. patching the .pro.user file, such that it sets the following automatically

  • used coding style
  • make rules
  • install rules

@tresf
Copy link
Member

tresf commented May 5, 2019

I've never had to do these things described. Running qmake seems like the wrong way though.

@JohannesLorenz
Copy link
Contributor Author

Did you maybe import the CMakeLists instead?

@tresf
Copy link
Member

tresf commented May 5, 2019

Yes, of course.

@JohannesLorenz
Copy link
Contributor Author

I found it confusing when importing CMakeLists (see the images above) - the additional CMake tree level, and finding out that the sources are in "src/lmmsobjs/". Maybe I'll get used to it...

What do others use?

@tresf
Copy link
Member

tresf commented May 5, 2019

I see the lmmsobjs folder structure a terrible argument to move away from an off-the-shelf solution that is used by millions.

@JohannesLorenz
Copy link
Contributor Author

I'm not getting QtCreator set up properly with CMake. If I use a CMake project, hold the mouse over Effect::processAudioBuffer and press ctrl+shift+u, it shows usages in include and plugins, but not in core. Does that work for you?

@rubiefawn
Copy link
Contributor

Just saw this. I'll take a look at those videos and work on understanding using QtCreator enough to make a tutorial.

@JohannesLorenz
Copy link
Contributor Author

@iansannar how far are you with the tutorial? 😄

@JohannesLorenz
Copy link
Contributor Author

I'll make a video tutorial now, unless anyone else wants to do it (or has already done it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants