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. Qt includes not working without path in include statement
Forum Update on Monday, May 27th 2025

Qt includes not working without path in include statement

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
9 Posts 3 Posters 1.6k Views
  • 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.
  • P Offline
    P Offline
    primem0ver
    wrote on 18 Dec 2018, 21:38 last edited by primem0ver
    #1

    My desktop Qt installation works fine, regardless if I point it to 5.5.1 or 5.10.0. I installed VS 2017 and Qt on my laptop so that I can work on my project in spare moments while visiting family over the holidays. I only have 5.5.1 on the destination machine (since that was the version I was using) and I have installed the extension for VS 2017. I can successfully set the target version. However, none of the include statements work on the laptop unless I add the subdirectory as part of the statement.

    For example, I must change
    #include <qstring.h> // to...
    #include <QtCore/qstring.h>

    Ultimately, I don't really care which format I use.... I just want it to be consistent so that what works on one computer will work on the other computer. Since things are currently without the subdirectory prefix, I would prefer that to work... but I can change if it is better. Is their a Qt setting or Visual Studio setting that will allow this to work on the new (or original) computer so that it is consistent?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Dec 2018, 22:01 last edited by
      #2

      Hi,

      The official way to do includes is:

      #include <QString>
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        primem0ver
        wrote on 18 Dec 2018, 22:44 last edited by
        #3

        Ok... but for whatever, reason, that is not working on the laptop. It says that the file is not found.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Dec 2018, 22:47 last edited by
          #4

          Did you try fo find that file in your Qt installation ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            primem0ver
            wrote on 18 Dec 2018, 23:48 last edited by
            #5

            Yes. They are all there. Every Qt file that I am trying to include is not found (there are many). It is not recursively traversing the qt folder to find included files. Yet there are no issues with the any of the files on my desktop. My guess is that either there is a VS 2017 setting that is different or there is something about the Qt extension/install on this computer that is different (in addition to its location).

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 19 Dec 2018, 20:02 last edited by
              #6

              How are you setting the project ?
              Are you starting from a .pro file ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Offline
                P Offline
                primem0ver
                wrote on 19 Dec 2018, 22:31 last edited by primem0ver
                #7

                No. The project has been done entirely in VS 2017. It was started as a new project on the desktop mentioned. I am not sure what you mean by "setting". I selected New=>Project from the File Menu in VS 2017 and then selected the traditional QT DLL project (or EXE in the single EXE case) type and went through the wizard from there. Then I re-selected the Qt version (as I usually have to do).

                To move to the laptop, I exported most of my VS 2017 settings and imported them on the laptop. I then moved the project as well. On the laptop, I used the default install directory for Qt. For the desktop I did not. However, that shouldn't matter as the QTDIR is an environment macro/variable (used in the "Additional Include Directories" tab only). I have read that sometimes the regular (not additional) VC++ include directories need to be set to fix this issue. However, the QTDIR macro is not available in this context. In addition, the QT plugin doesn't seem to mess with these settings. Since you say that a simple #include <qstring.h> is normal, I am assuming that it should not be necessary to change things...

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  primem0ver
                  wrote on 20 Dec 2018, 00:46 last edited by
                  #8

                  I think I figured out the problem, I am not sure why it occurred though. In the Qt project settings, none of the modules I checked when I created the project (and still exist on the other machine) are checked. Apparently the VS plugin adds the appropriate directory to additional includes when the modules are checked. For whatever reason, these settings did not transfer to the laptop.

                  P 1 Reply Last reply 20 Dec 2018, 14:46
                  0
                  • P primem0ver
                    20 Dec 2018, 00:46

                    I think I figured out the problem, I am not sure why it occurred though. In the Qt project settings, none of the modules I checked when I created the project (and still exist on the other machine) are checked. Apparently the VS plugin adds the appropriate directory to additional includes when the modules are checked. For whatever reason, these settings did not transfer to the laptop.

                    P Offline
                    P Offline
                    Pablo J. Rogina
                    wrote on 20 Dec 2018, 14:46 last edited by
                    #9

                    @primem0ver glad you solved your issue, please don't to forget to mark your post as such. Thanks!

                    Upvote the answer(s) that helped you solve the issue
                    Use "Topic Tools" button to mark your post as Solved
                    Add screenshots via postimage.org
                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    0

                    1/9

                    18 Dec 2018, 21:38

                    • Login

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