[SOLVED] [File Organization] Creating an organized project with Qt Creator
-
I'm not sure how actually do this in Qt Creator. Do you create a new Qt Creator plugin project and modify the .pri so that they get included in your project?
-
I usually just do New->Text File and change the extension to .pri!
-
Ok, now I understand. You write it manually initially, then Qt Creator takes cares of it.
Thanks!
-
Yeah, sorry I should have mentioned that. Maybe if have time, I'll code a wizard for that and do a merge request.
-
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!
-
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@ -
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.
-
I used this link to get information : http://stackoverflow.com/questions/1417776/how-to-use-qmakes-subdirs-template
-
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.
-
The only thing I could see that would cause that would be using absolute paths. Can you show us your .pro file?
-
@#-------------------------------------------------
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 = appSOURCES += main.cpp
mainwindow.cpp \HEADERS += mainwindow.h
singularity.hOTHER_FILES +=@
-
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.
-
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.
-
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.
-
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.