How to create a modular structure of the project, as shown:

enter image description here

So that in the src folder there were modules consisting of .pri files, headers of .h files, ui and .cpp files. Now everything is in the heap:

enter image description here

What is there to choose? :

enter image description here

  • Yes, it seems, it’s not necessary to change the type of project, but simply add the "modules". - outoftime
  • @outoftime And for more details, you can? So what’s not clear and I’m not changing the type of project, but adding files to the project - Ivan Triumphov
  • one
    Modular application: github.com/gil9red/NotesManager . In the pro file, the following modules are connected via include : include( Manager/Manager.pri ) - gil9red
  • @ gil9red And how to create such modules yourself with .pri files? This is the question - Ivan Triumphov
  • one
    Create it as a plain text file and add to your project a line in the pro file, as you were shown above - Bearded Beaver

1 answer 1

For QtCreator 4.5:

Create> Other project> Project with subdirectories

A project will be created where you can add subprojects. It will be possible to specify the relationship between them, from which the compilation order is automatically calculated.

However, I recommend manually writing pro-files.

 TEMPLATE = subdirs #Π’ΠΈΠΏ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π° CONFIG += ordered #Π‘ΠΎΠ±ΠΈΡ€Π°Π΅ΠΌ ΠΏΠΎ порядку, ΠΊΠ°ΠΊ ΡƒΠΊΠ°Π·Π°Π½ΠΎ SUBDIRS += \ osm_elements \ tests \ osm_widget tests.depends = osm_widget #Π’Π°ΠΊ обозначаСтся Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡ‚ΡŒ osm_widget.depends = osm_elements 

The code corresponds to this structure

TEMPLATE indicates the type of project. In this case, the project with subdirectories.

 TEMPLATE=app #ΠŸΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ TEMPLATE=lib #Π‘ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠ° TEMPLATE=subdirs #ΠŸΡ€ΠΎΠ΅ΠΊΡ‚ с ΠΏΠΎΠ΄ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°ΠΌΠΈ 

Check the QtCreator help, qmake, Getting Started section.