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. [SOLVED] qtcreator ui-> autocompletion doesn't work if I split some funcs out of the original .cpp
QtWS25 Last Chance

[SOLVED] qtcreator ui-> autocompletion doesn't work if I split some funcs out of the original .cpp

Scheduled Pinned Locked Moved Qt Creator and other tools
5 Posts 2 Posters 2.1k 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.
  • I Offline
    I Offline
    i92guboj
    wrote on last edited by
    #1

    Hello.

    This is a complete newbie question so just bear with me :P

    I've been working with qtcreator for many months and autocompletion has always worked fine. Now, the critter has gotten big enough, and I am taking some time to organise a bit my code. In the process I took some related methods and put them into a separate .cpp file, #including in turn that new .cpp file into the old (bigger) one. So far, it compiles fine as expected.

    But, when I went back to qtcreator to continue coding, I discovered that completion doesn't work any more with the ui class. It seems to work still for all my custom classes though.

    I am not using any #include in that split cpp file. From the C++ point of view I don't think it's necessary, but qtcreator doesn't seem to think the same. If I #include back the main cpp file into the new one, then completion works, but, of course, compilation fails due to duplicate declarations and all that.

    So, what's the proper way to make completion work when you split one big cpp file into several ones?

    Thank you! :)

    1 Reply Last reply
    0
    • W Offline
      W Offline
      WoJo
      wrote on last edited by
      #2

      you should avoid to includ cpp files. but you can include the header file in both cpp files. so you have completition in both and it compiles correctly.

      Header:
      @// MyClass.h
      class MyClass {
      public:
      void method1();
      void method2();
      };@

      Source file 1
      @// MyClass1.cpp
      #include "MyClass.h"

      MyClass::method1() {
      // code
      }@

      Source file 2
      @//MyClass2.cpp
      #include "MyClass.h"
      MyClass::method2() {
      // code
      }@

      1 Reply Last reply
      0
      • I Offline
        I Offline
        i92guboj
        wrote on last edited by
        #3

        Thanks but I also tried that. It works for everything I have written myself, but it doesn't seem to catch ui-> completion. It compiles and all that if I write it myself, so ui is in the scope, but autocompletion for that class just doesn't work on the splitted cpp file.

        It has always worked (and still works) without problems in the original cpp file... Maybe there's some setting in qtcreator that controls that?

        1 Reply Last reply
        0
        • W Offline
          W Offline
          WoJo
          wrote on last edited by
          #4

          where is the include of the "ui_XYZ.h" file? If it is in the first .cpp file, just include it in the second one or move the include to the header file.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            i92guboj
            wrote on last edited by
            #5

            Thanks. That was it. :)

            Including it to the .h file worked.

            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