Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why need ../ to include the path in Qt5?
Forum Updated to NodeBB v4.3 + New Features

Why need ../ to include the path in Qt5?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.3k 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.
  • M Offline
    M Offline
    mameo
    wrote on last edited by
    #1

    Hi,

    I transplanted the source that was made with Qt4 to Qt5.
    Inclusion of compilation errors had out a lot.

    When an attempt is made to include the file in a different folder,
    You do not specify the ../ and it becomes a compile error.
    It was no problem in Qt4.
    Do I need something set?

    <Folder structure>

    • sample
      main.cpp
      • Model
        SampleModel.h, SampleModel.cpp
      • Data
        SampleData.h, SampleData.cpp

    <Qt4 source code of>
    / * SampleModel.h * /
    #include "Data / SampleData.h"

    <Qt5 source code of>
    #include "Data / SampleData.h" // error
    #include "../Data/SampleData.h"

    Use environment: Windows7 64bit, QtCreator 3.3.0, Qt5.4.0

    Best regards,

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      The paths depend on what you put in INCLUDEPATH variable in .pro file.

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mameo
        wrote on last edited by
        #3

        I'm sorry. I do not know what to do with.

        I tried to add a INCLUDEPATH, but you get an error.
        Error content is below.
        C1083: 'Data / SampleData.h' No such file or directory.
        @

        #Sample.pro
        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = Sample
        TEMPLATE = app

        INCLUDEPATH +=
        Data \

        SOURCES += main.cpp
        Data/SampleData.cpp
        Model/SampleModel.cpp

        HEADERS +=
        Data/SampleData.h
        Model/SampleModel.h

        FORMS += \

        @
        Thank you.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Try
          @
          #include "SampleData.h"
          @

          There was no change here between Qt 4 and 5, so it really should work.

          (Z(:^

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mameo
            wrote on last edited by
            #5

            I solved the problem.
            It was resolved by adding a $$ PWD to include path.


            QT += core gui

            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

            TARGET = Sample
            TEMPLATE = app

            INCLUDEPATH += $$PWD

            SOURCES += main.cpp
            Data/SampleData.cpp
            Model/SampleModel.cpp

            HEADERS += Data/SampleData.h
            Model/SampleModel.h

            Mr. sierdzio.
            Thank you tell me.

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              Hm, that is unusual, but good that you've found this out. Happy coding!

              (Z(:^

              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