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. New user - Qt5 Creator IDE displaying 'errors' although compiles ok
QtWS25 Last Chance

New user - Qt5 Creator IDE displaying 'errors' although compiles ok

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.8k 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.
  • J Offline
    J Offline
    JohnM64
    wrote on last edited by JohnM64
    #1

    Hi - I've just installed Qt5 Creator in my Ubuntu 20.04 LTS system, and trying to get something, anything, to build. It's very frustrating; I was expecting this to be easy.

    For example, if I open the Analog Clock example project, it says I need to copy it into a writable location to be able to compile it. No problem - I choose a directory under my /home/user directory.

    The project opens in the main.cpp, and the 2nd #include, of "rasterwindow.h", is underlined in red with a "file not found" error on the right hand side. I'm pretty new to Qt but I suspect the problem is in the .pro file, which has:

    include(../rasterwindow/rasterwindow.pri)
    

    That rasterwindow directory doesn't exist where the project has been copied to. So I create a symbolic link to where it does exist. And if I close the project and re-open it, the #include "rasterwindow.h" is no longer underlined. But on the next line:

    class AnalogClockWindow : public RasterWindow
    

    the RasterWindow is underlined in red, with the error "expected class name".

    At this point I give up and try creating my own simple Qt Widgets app. I accept all the defaults, and I'm presented with main.cpp:

    #include "mainwindow.h"
    
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w:
        :
    

    But QApplication has error "variable has incomplete type 'QApplication'", with error "unknown type name 'MainWindow'" below.

    I've obviously got something fundamentally wrong somewhere; please can anyone help?

    Cheers
    John

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JohnM64
      wrote on last edited by
      #2

      Well, actually I can build things, but not within Qt Creator.

      I can build both the (copy of the) analog clock example, and my own stub app, by running qmake in the project's directory followed by make. No errors, and the executables run fine. (Although I still need to create the local rasterwindow symbolic link for the analog clock.)

      So the problem must presumably be something in my Qt Creator settings.

      JonBJ 1 Reply Last reply
      0
      • J JohnM64

        Well, actually I can build things, but not within Qt Creator.

        I can build both the (copy of the) analog clock example, and my own stub app, by running qmake in the project's directory followed by make. No errors, and the executables run fine. (Although I still need to create the local rasterwindow symbolic link for the analog clock.)

        So the problem must presumably be something in my Qt Creator settings.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @JohnM64
        Assuming you mean the code compiles fine, but these are warnings you see only when editing in Creator. It is the "code model parser" in the IDE which is showing these errors. Under Ubuntu 20.04 you need to replace the shipped clang version 8 by up-to-date version 9. I think it's sudo apt-get install clang-9, or similar.

        J 1 Reply Last reply
        2
        • JonBJ JonB

          @JohnM64
          Assuming you mean the code compiles fine, but these are warnings you see only when editing in Creator. It is the "code model parser" in the IDE which is showing these errors. Under Ubuntu 20.04 you need to replace the shipped clang version 8 by up-to-date version 9. I think it's sudo apt-get install clang-9, or similar.

          J Offline
          J Offline
          JohnM64
          wrote on last edited by JohnM64
          #4

          @JonB thanks, but I've installed clang9 (actually clang --version says it's 10.0.0-4ubuntu1), restarted Qt Creator, and I'm still getting the same 'errors' displayed in the IDE.

          qt.png

          (I've updated the thread title to reflect recent discoveries.)

          JonBJ 1 Reply Last reply
          0
          • J JohnM64

            @JonB thanks, but I've installed clang9 (actually clang --version says it's 10.0.0-4ubuntu1), restarted Qt Creator, and I'm still getting the same 'errors' displayed in the IDE.

            qt.png

            (I've updated the thread title to reflect recent discoveries.)

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @JohnM64
            That surprises me, because it looks exactly like what I expected for the clang issue....

            Go check the setting, wherever it is in Designer, showing just what clang it is using (for "Code Model", it has a setting page somewhere)? There you can change over to whatever the simpler, non-clang option is temporarily, to verify it's a clang issue?

            J 1 Reply Last reply
            1
            • JonBJ JonB

              @JohnM64
              That surprises me, because it looks exactly like what I expected for the clang issue....

              Go check the setting, wherever it is in Designer, showing just what clang it is using (for "Code Model", it has a setting page somewhere)? There you can change over to whatever the simpler, non-clang option is temporarily, to verify it's a clang issue?

              J Offline
              J Offline
              JohnM64
              wrote on last edited by JohnM64
              #6

              @JonB
              Apologies for the delay; for reasons I won't bore you with I'm now running under Xubuntu.

              Anyway, it looks like the problem is solved. Under Tools / Options / C++ / Code Model / Clang Code Model it said it was enabled because the plugin was loaded. So I went into Help / About Plugins... and unticked the Load tick-boxes for C++ / ClangCodeModel and Code Analyzer / ClangTools. Might not have needed to untick both of them, but I couldn't be bothered to fine tune it.

              Don't know if this will have negative side effects, but everything looks ok so far.

              Thanks for the help.

              Cheers
              John

              JonBJ 1 Reply Last reply
              0
              • J JohnM64

                @JonB
                Apologies for the delay; for reasons I won't bore you with I'm now running under Xubuntu.

                Anyway, it looks like the problem is solved. Under Tools / Options / C++ / Code Model / Clang Code Model it said it was enabled because the plugin was loaded. So I went into Help / About Plugins... and unticked the Load tick-boxes for C++ / ClangCodeModel and Code Analyzer / ClangTools. Might not have needed to untick both of them, but I couldn't be bothered to fine tune it.

                Don't know if this will have negative side effects, but everything looks ok so far.

                Thanks for the help.

                Cheers
                John

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @JohnM64
                Well this hasn't resolved the issue of getting your clang code model working in Creator, it has just switched it off! You will get a different editing aid experience. If you are happy without clang that is OK for you.

                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