Results 1 to 4 of 4

Thread: Include path question

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Red face Include path question

    Hi to all!

    In my project, I have following directory structure:
    Qt Code:
    1. Folder PATH listing
    2. Volume serial number is 0000-0000
    3. C:.
    4. │ PresernMkI.pro
    5. │ PresernMkI.pro.user
    6. │
    7. ├───includes
    8. │ mainwindow.h
    9. │
    10. ├───libs
    11. ├───src
    12. │ main.cpp
    13. │ mainwindow.cpp
    14. │
    15. └───ui
    To copy to clipboard, switch view to plain text mode 

    Now, in file mainwindow.cpp, how do i include mainwindow.h? Code
    Qt Code:
    1. #include "../include/mainwindow.h"
    To copy to clipboard, switch view to plain text mode 
    does not work since I get compiler errors regarding missing mainwindow.h file. Please help me!

    Sincerely,
    Marko
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Include path question

    You can use makefile variables in your .pro to specifiy your include path.
    INCLUDEPATH may be useful for you.

    Others are described there :
    http://qt.nokia.com/doc/4.5/qmake-va...reference.html

    Then you just need to include headers
    Qt Code:
    1. #include "mainwindow.h"
    To copy to clipboard, switch view to plain text mode 
    Last edited by scascio; 28th September 2009 at 13:17. Reason: formatting

  3. The following user says thank you to scascio for this useful post:

    MarkoSan (28th September 2009)

  4. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Include path question

    And your directory is named includes not include (as you have written in your #include).

    Using ".." in #include should work, otherwise.
    (Use it only in headers that are private or for .cpp files, though.)

  5. The following user says thank you to caduel for this useful post:

    MarkoSan (28th September 2009)

  6. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Talking Re: Include path question

    Quote Originally Posted by scascio View Post
    You can use makefile variables in your .pro to specifiy your include path.
    INCLUDEPATH may be useful for you.

    Others are described there :
    http://qt.nokia.com/doc/4.5/qmake-va...reference.html

    Then you just need to include headers
    Qt Code:
    1. #include "mainwindow.h"
    To copy to clipboard, switch view to plain text mode 
    Wow, thank a lot, man!!!! It works now ...
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. Include path confusion in Qt with Eclipse
    By PUK_999 in forum Installation and Deployment
    Replies: 0
    Last Post: 20th August 2009, 20:56
  2. segmentation fault on closing
    By harakiri in forum Qt Programming
    Replies: 6
    Last Post: 8th July 2009, 13:54
  3. qt #include question
    By marf in forum Newbie
    Replies: 1
    Last Post: 27th July 2008, 08:40
  4. Error: Using Multiple files
    By 3nc31 in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 09:23
  5. use button from another Window
    By raphaelf in forum Qt Programming
    Replies: 11
    Last Post: 2nd March 2006, 20:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.