'QObject' file not found in Qt 6.6.1
-
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?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? -
@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.
-
-
@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. -
-
@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
-
@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>
? -
@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.
-
@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.
-
-
@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.
-
@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. -