Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QtCreator autocomplete not working (headers included elsewhere)
Forum Updated to NodeBB v4.3 + New Features

QtCreator autocomplete not working (headers included elsewhere)

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.9k 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.
  • S Offline
    S Offline
    szczurcio
    wrote on last edited by
    #1

    Hello,
    I'm a Qt newbie.
    Today I've noticed that if I include my header files in another file - let's say I have a file, Utilities.cpp, and that file is included in my mainwindow.h header (where QTextStream is included), which in turn is included in mainwindow.cpp - then the autocomplete will not work when I write code using the QTextStream class in Utilities.cpp. In short, it seems that for the autocomplete to work the given header file must be included in the very same file I'm writing to.

    Is there any way around this?

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

      This is Qt Creator teaching you how to code correctly. If you use a class in a file, include it's header. Always. Even if you have already included it elsewhere.

      The reasons for this are the following:

      1. When you rearrange the code, it may happen that the compiler will loos the view of a header included in another file. You will be flooded with error messages about X not being defined, or an incomplete class, etc. If you always include all the headers you need in the file, you will never have this problem.
      2. Making sure you only inlcude the headers you need and where you need them will speed up compilation.

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        szczurcio
        wrote on last edited by
        #3

        Indeed, that works beautifully. Thanks a lot :)

        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