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. How to let intellisense knows about non-self contain symbols in header files that
Forum Update on Monday, May 27th 2025

How to let intellisense knows about non-self contain symbols in header files that

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 2 Posters 342 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by jronald
    #1

    As below, b.h references class A in a.h, but b.h doesn't include a.h directly but indirectly instead.
    The code can be built successfully.
    The problem is tht Qt Creator shows a warning for class A in b.h, for it doesn't know class A, and navigation to class A failed.
    How to fix the problem without adding #include <path\to\a.h> in b.h?

    a.h

    class A
    {
        ...
    }
    

    b.h

    void test(A a);
    

    b.cpp

    #include "a.h"
    #include "b.h"
    
    void test(A a)
    {
       ...
    }
    
    JonBJ 1 Reply Last reply
    0
    • jronaldJ jronald

      As below, b.h references class A in a.h, but b.h doesn't include a.h directly but indirectly instead.
      The code can be built successfully.
      The problem is tht Qt Creator shows a warning for class A in b.h, for it doesn't know class A, and navigation to class A failed.
      How to fix the problem without adding #include <path\to\a.h> in b.h?

      a.h

      class A
      {
          ...
      }
      

      b.h

      void test(A a);
      

      b.cpp

      #include "a.h"
      #include "b.h"
      
      void test(A a)
      {
         ...
      }
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @jronald said in How to let intellisense knows about non-self contain symbols in header files that:

      The problem is tht Qt Creator shows a warning for class A in b.h, for it doesn't know class A, and navigation to class A failed.

      Yes, that looks like correct behaviour to me.

      How to fix the problem without adding #include <path\to\a.h> in b.h?

      I would not expect you would need a path to .a.h, b.cpp manages with #include "a.h". I would expect b.h to include a.h.

      You could put class A; before void test(A a); into b.h, so that it knows A is an external class, but I don't think it would help much.

      I don't see how you expect b.h to know about class A, or how to navigate to it etc., if you're not prepared to include a.h into it.

      jronaldJ 1 Reply Last reply
      0
      • JonBJ JonB

        @jronald said in How to let intellisense knows about non-self contain symbols in header files that:

        The problem is tht Qt Creator shows a warning for class A in b.h, for it doesn't know class A, and navigation to class A failed.

        Yes, that looks like correct behaviour to me.

        How to fix the problem without adding #include <path\to\a.h> in b.h?

        I would not expect you would need a path to .a.h, b.cpp manages with #include "a.h". I would expect b.h to include a.h.

        You could put class A; before void test(A a); into b.h, so that it knows A is an external class, but I don't think it would help much.

        I don't see how you expect b.h to know about class A, or how to navigate to it etc., if you're not prepared to include a.h into it.

        jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote on last edited by jronald
        #3

        @JonB said in How to let intellisense knows about non-self contain symbols in header files that:

        I don't see how you expect b.h to know about class A

        Visual Studio is smart enough to know class A in b.h in this case.

        But I think #include "a.h" in b.h is the essential way.

        Thanks

        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