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. 'QObject' file not found in Qt 6.6.1
Forum Updated to NodeBB v4.3 + New Features

'QObject' file not found in Qt 6.6.1

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
11 Posts 3 Posters 2.2k 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.
  • M MyNameIsQt

    I am reposting a previously posted question.
    I originally developed it in a 6.4.3 environment, but my hard disk broke, so I had to install qt on a new hard disk. The version is 6.6.1. An error occurred when a project developed in 6.4.3 was opened in 6.6.1. Why did I get this error?

    4c99ea27-533b-4a4e-bf6b-5661002119d6.png

    Should I delete this and go back to 6.4.3?
    However, I will release this project as open source. Therefore, I think that it should be able to be used without problems regardless of the version of QT Creator that the developer uses. How can I fix this?

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

    @MyNameIsQt
    The only error here is the first one showing it can't find <QObject>. Make sure you installed properly, check the .pro file and look to see where the compiler is looking for this and that the necessary files are there.

    M 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop on
    • JonBJ JonB

      @MyNameIsQt
      The only error here is the first one showing it can't find <QObject>. Make sure you installed properly, check the .pro file and look to see where the compiler is looking for this and that the necessary files are there.

      M Offline
      M Offline
      MyNameIsQt
      wrote on last edited by
      #3

      @JonB
      This is the front part of the .pro file. Is there anything I need to fix here?

      QT       += core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      CONFIG += c++11
      
      # You can make your code fail to compile if it uses deprecated APIs.
      # In order to do so, uncomment the following line.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      # install targets
      target.path = /opt/WPubViewer
      INSTALLS += target
      
      
      JonBJ 1 Reply Last reply
      0
      • M MyNameIsQt

        @JonB
        This is the front part of the .pro file. Is there anything I need to fix here?

        QT       += core gui
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        CONFIG += c++11
        
        # You can make your code fail to compile if it uses deprecated APIs.
        # In order to do so, uncomment the following line.
        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
        
        # install targets
        target.path = /opt/WPubViewer
        INSTALLS += target
        
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #4

        @MyNameIsQt
        Does it actually build? Your screenshot only shows editor complaining. If that's the case it's some Code Completion issue not finding what it needs to. If you restored project from elsewhere make sure you have cleaned out any generated files and start from scratch.

        If you create a brand new, simplest Qt GUI project does that find the #include <QObject>?

        M 1 Reply Last reply
        1
        • JonBJ JonB

          @MyNameIsQt
          Does it actually build? Your screenshot only shows editor complaining. If that's the case it's some Code Completion issue not finding what it needs to. If you restored project from elsewhere make sure you have cleaned out any generated files and start from scratch.

          If you create a brand new, simplest Qt GUI project does that find the #include <QObject>?

          M Offline
          M Offline
          MyNameIsQt
          wrote on last edited by
          #5

          @JonB I created a small test project. The result is the same.

          화면 캡처 2023-12-30 134154.jpg

          JonBJ 1 Reply Last reply
          0
          • M MyNameIsQt

            @JonB I created a small test project. The result is the same.

            화면 캡처 2023-12-30 134154.jpg

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

            @MyNameIsQt
            You choose to show an error on #include "mainwindow.h", your own file, and have even chopped off the error message. This is not helpful as we cannot tell what the first error actually is.

            Most importantly I asked whether the errors are only in the editor or whether they happen when you actually compile, which you chose not to answer.

            M 1 Reply Last reply
            0
            • JonBJ JonB

              @MyNameIsQt
              You choose to show an error on #include "mainwindow.h", your own file, and have even chopped off the error message. This is not helpful as we cannot tell what the first error actually is.

              Most importantly I asked whether the errors are only in the editor or whether they happen when you actually compile, which you chose not to answer.

              M Offline
              M Offline
              MyNameIsQt
              wrote on last edited by
              #7

              @JonB This happens in the editor. Of course, no compilation takes place.

              JonBJ 1 Reply Last reply
              0
              • M MyNameIsQt

                @JonB This happens in the editor. Of course, no compilation takes place.

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

                @MyNameIsQt said in 'QObject' file not found in Qt 6.6.1:

                Of course, no compilation takes place.

                What does this mean? Compilation takes place if you ask it to compile. And I asked what happens if you do that, but still no answer. There are two possibilities:

                • There is a genuine problem with the code/locating the includes. In which case you will get a compilation error. And then you can show (at least the first) error message from the compiler together with the command line invoking it.

                • The code compiles fine. In which case the problem lies only in the Code Completion model used in the editor, whose settings you can go look at, maybe update the clang or some other adjustment.

                I'm not going to keep asking for the necessary information to help diagnose your issue. You seem to want to do it your way so I will leave you to it, perhaps someone else will want to answer while not knowing whether it is a code completion or a compilation problem.

                Axel SpoerlA M 3 Replies Last reply
                0
                • JonBJ JonB

                  @MyNameIsQt said in 'QObject' file not found in Qt 6.6.1:

                  Of course, no compilation takes place.

                  What does this mean? Compilation takes place if you ask it to compile. And I asked what happens if you do that, but still no answer. There are two possibilities:

                  • There is a genuine problem with the code/locating the includes. In which case you will get a compilation error. And then you can show (at least the first) error message from the compiler together with the command line invoking it.

                  • The code compiles fine. In which case the problem lies only in the Code Completion model used in the editor, whose settings you can go look at, maybe update the clang or some other adjustment.

                  I'm not going to keep asking for the necessary information to help diagnose your issue. You seem to want to do it your way so I will leave you to it, perhaps someone else will want to answer while not knowing whether it is a code completion or a compilation problem.

                  Axel SpoerlA Offline
                  Axel SpoerlA Offline
                  Axel Spoerl
                  Moderators
                  wrote on last edited by
                  #9

                  @JonB
                  That typically happens, when a project imports binaries, which have been created with an older compiler version and/or an older Qt version. I suspect, that the project actually compiles.

                  Best to wipe the binary directory completely, rebuild the project and then use the Build->Rescan Project function of Qt Creator. That usually fixes code model issues.

                  Software Engineer
                  The Qt Company, Oslo

                  1 Reply Last reply
                  0
                  • JonBJ JonB

                    @MyNameIsQt said in 'QObject' file not found in Qt 6.6.1:

                    Of course, no compilation takes place.

                    What does this mean? Compilation takes place if you ask it to compile. And I asked what happens if you do that, but still no answer. There are two possibilities:

                    • There is a genuine problem with the code/locating the includes. In which case you will get a compilation error. And then you can show (at least the first) error message from the compiler together with the command line invoking it.

                    • The code compiles fine. In which case the problem lies only in the Code Completion model used in the editor, whose settings you can go look at, maybe update the clang or some other adjustment.

                    I'm not going to keep asking for the necessary information to help diagnose your issue. You seem to want to do it your way so I will leave you to it, perhaps someone else will want to answer while not knowing whether it is a code completion or a compilation problem.

                    M Offline
                    M Offline
                    MyNameIsQt
                    wrote on last edited by MyNameIsQt
                    #10

                    @JonB

                    Of course it doesn't compile. I think the picture explains it well.
                    I uninstalled 6.6.1 and reinstalled the 6.4.3 I was originally using. But the result is the same.

                    화면 캡처 2024-01-01 033910.jpg

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @MyNameIsQt said in 'QObject' file not found in Qt 6.6.1:

                      Of course, no compilation takes place.

                      What does this mean? Compilation takes place if you ask it to compile. And I asked what happens if you do that, but still no answer. There are two possibilities:

                      • There is a genuine problem with the code/locating the includes. In which case you will get a compilation error. And then you can show (at least the first) error message from the compiler together with the command line invoking it.

                      • The code compiles fine. In which case the problem lies only in the Code Completion model used in the editor, whose settings you can go look at, maybe update the clang or some other adjustment.

                      I'm not going to keep asking for the necessary information to help diagnose your issue. You seem to want to do it your way so I will leave you to it, perhaps someone else will want to answer while not knowing whether it is a code completion or a compilation problem.

                      M Offline
                      M Offline
                      MyNameIsQt
                      wrote on last edited by
                      #11

                      @JonB
                      Currently I updated win 7 to win10 on another hard disk and reinstalled everything. (qt and visual studio 2022). Currently everything is working fine.
                      I suspect it is caused by onedrive being included in the project file path. But nothing is certain. Thank you very much for your interest and response.

                      1 Reply Last reply
                      0
                      • M MyNameIsQt has marked this topic as solved on

                      • Login

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