Re: Difference between own headers and Qt's headers

Originally Posted by
Binary91
If someone could answer me this (simple) question?
Put simply, when you tell Qt which module(s) you're using via the QT project variable (i.e. QT += core widgets network sql, etc.), Qt will automatically provide the correct include paths and library paths/modules for linking. This is all handled by qmake.
If your personal code is available via library (static or dynamic), then you would not need to add the source code via the SOURCES project variable, you would simply tell Qt which library(s) to link against and where to find them using the LIBS qmake variable for example (-L for the library directories to search and -l for the library names to include, i.e. -L /home/user/include -l mylibrary)
If your personal code only exists in source files, then you must incorporate those source files into your project, so that they are compiled and available to link your executable.
Look at the compiler output window of Qt Creator or command line make output (or qmake generated make files) and you'll see where the Qt include and library paths are automatically passed to the compiler using -I and linker steps are passed -L and -l to find/resolve the Qt code that you told qmake you will use based on the QT project variable.
So, for built-in Qt stuff, Qt knows where your include and library files are installed, so qmake does most of the setup for you. For your own personal files, you have to tell qmake where your headers and library paths are, as well as any library name(s) to link with. If your code is not in library form, then you must take the additional step to include that code into your project, which will be compiled and linked with your qmake target.
Make sense?
Last edited by jefftee; 7th July 2015 at 06:06.
I write the best type of code possible, code that I want to write, not code that someone tells me to write!
Bookmarks