Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] [File Organization] Creating an organized project with Qt Creator
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] [File Organization] Creating an organized project with Qt Creator

Scheduled Pinned Locked Moved Qt Creator and other tools
21 Posts 6 Posters 41.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    valandil211
    wrote on last edited by
    #11

    Yes, that would be incredibly helpful. However, I'm sure a little noob documentation in Qt Creator itself could be good. It may be my fault, but I didn't find anything in Qt Creator's docs about that.

    Anyway, thank you for your answers!

    Joey Dumont

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Plissken
      wrote on last edited by
      #12

      Sorry to play threadcromancer, but I want to organize my files like this. I can see how to create a new text file and rename it to .pri, but it just gets sorted under Other Files. Never worked with plugins before. Can someone please write a step-by-step on how to organize files like in the image posted above?

      EDIT: Hm...ok I'm guessing it's add library? Didn't think of that before. BTW, what does the following mean for the .pri file? Specifically $$PWD?

      @INCLUDEPATH += $$PWD
      DEPENDPATH += $$PWD@

      1 Reply Last reply
      0
      • V Offline
        V Offline
        valandil211
        wrote on last edited by
        #13

        When you create add a text file and rename to .pri in Qt Creator, it will take some time before Qt Creator parses your new files and recognizes the new folder structure. When it does, your project will look like the picture above.

        And $$PWD dereferences the environment variable PWD, or print working directory, which is the directory you set for your project in Qt Creator, if I remember well.

        Joey Dumont

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Skylar
          wrote on last edited by
          #14

          I used this link to get information : http://stackoverflow.com/questions/1417776/how-to-use-qmakes-subdirs-template

          In most cases, the bug is mine. But of the remaining lines are correct.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Plissken
            wrote on last edited by
            #15

            So I got this stuff working. I uploaded the project to a git repository and cloned it to another computer. However, the project fails to recognize pretty much every header file, one at a time. For example it says it doesn't recognize one header file, but if I comment that out, then it doesn't recognize a different header file, and so on. Any ideas on why Qt won't recognize on one computer while it recognizes and compiles fine on the other? All the pri files and pro files are unchanged from the working computer.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              valandil211
              wrote on last edited by
              #16

              The only thing I could see that would cause that would be using absolute paths. Can you show us your .pro file?

              Joey Dumont

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Plissken
                wrote on last edited by
                #17

                @#-------------------------------------------------

                Project created by QtCreator 2012-06-27T21:24:38

                #-------------------------------------------------
                include(internal_lib/statsheet/statsheet.pri)
                include(internal_lib/widgets/widgets.pri)
                include(internal_lib/utility/utility.pri)

                QT += core gui

                TARGET = Singularity
                TEMPLATE = app

                SOURCES += main.cpp
                mainwindow.cpp \

                HEADERS += mainwindow.h
                singularity.h

                OTHER_FILES +=@

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  valandil211
                  wrote on last edited by
                  #18

                  Ok, I'm lost.

                  What do you comment out for a header file not to be recognized? And what do you mean, not recognized? It doesn't show up in the left-hand-side list? Since I use .pri files, I always get the hierarchy shown by loladiro.

                  Joey Dumont

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Plissken
                    wrote on last edited by
                    #19

                    By not recognized I mean a compiler error. The error that I get is:

                    error: C1083: Cannot open include file: 'internal_lib/widgets/sheet_wp.h': No such file or directory

                    I tried commenting out the include statement that includes sheet_wp.h, but I only got another of the same error but for a different header file. It's strange because Qt Creator recognizes all the files in the Project pane and all the files are in the right folders.

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      Plissken
                      wrote on last edited by
                      #20

                      Wow. Fixed it but I don't completely understand why it worked. I looked up the definition of PWD because I didn't fully understand what it meant:

                      "The PWD variable specifies the full path leading to the directory containing the current file being parsed. This can be useful to refer to files within the source tree when writing project files to support shadow builds."

                      The word shadow builds caught my attention. I noticed that on the original project it was using a shadow build and the ones I've copied over weren't. I reloaded the pro file and this time selected shadow build option, now it compiles fine.

                      1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        Nathaniel Johnson
                        wrote on last edited by
                        #21

                        Having just worked through this issue in QT Creator I found that the (simple) thing I didn't notice before if you click on the funnel shaped icon in the project view and un-check the Simplify Tree option it makes it look like the "loladiro picture":http://qt-project.org/forums/viewthread/6971/#40658 .

                        I also did not get this to work:

                        @INCLUDEPATH += $$PWD
                        DEPENDPATH += $$PWD
                        SOURCES += source1.h
                        source2.h
                        HEADERS += header1.h
                        header2.h
                        @

                        So instead I did this:

                        @CURRENT_DIR = $$PWD
                        SOURCES += $$CURRENT_DIR/source1.cpp
                        HEADERS += $$CURRENT_DIR/source1.h@

                        This works for me BUT
                        If someone has time to explain, I would be curious to know why why modifying the INCLUDEPATH and DEPENDPATH variables didn't work.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved