Error "file not found"
-
Qt does not see the connected headers, when trying to include the header, it gives the error "file not found". I will be grateful for help with solving this problem.
-
Qt does not see the connected headers, when trying to include the header, it gives the error "file not found". I will be grateful for help with solving this problem.
@Nik_prog04
Hello and welcome.Do you have a
.pro
file for your project? Have you put into that which Qt modules your project will be using? -
Qt does not see the connected headers, when trying to include the header, it gives the error "file not found". I will be grateful for help with solving this problem.
@Nik_prog04 Did you already build your project? QtCreator can show such errors until you build your project.
-
@Nik_prog04 Did you already build your project? QtCreator can show such errors until you build your project.
-
@jsulm
Correct me if I am wrong, but I believe failure to find file for#include <QMainWindow>
does not arise prior to first build, it indicates it is not looking for the header file in the right place? -
@JonB said in Error "file not found":
Correct me if I am wrong, but I believe failure to find file for #include <QMainWindow> does not arise prior to first build, it indicates it is not looking for the header file in the right place?
He doesn't see any header files at all. Building a project does not affect this in any way. Perhaps you are right, you need to change the path that the header files will be searched for, but I still can't find how to change this path and which one to change it to.
-
@JonB said in Error "file not found":
Correct me if I am wrong, but I believe failure to find file for #include <QMainWindow> does not arise prior to first build, it indicates it is not looking for the header file in the right place?
He doesn't see any header files at all. Building a project does not affect this in any way. Perhaps you are right, you need to change the path that the header files will be searched for, but I still can't find how to change this path and which one to change it to.
@Nik_prog04 Please show your pro file...
-
@JonB said in Error "file not found":
Correct me if I am wrong, but I believe failure to find file for #include <QMainWindow> does not arise prior to first build, it indicates it is not looking for the header file in the right place?
He doesn't see any header files at all. Building a project does not affect this in any way. Perhaps you are right, you need to change the path that the header files will be searched for, but I still can't find how to change this path and which one to change it to.
@JonB said in Error "file not found":
Do you have a
.pro
file for your project? Have you put into that which Qt modules your project will be using? -
@JonB Could be. But with this code model errors it is always a good idea to build and see whether they disappear :-)
@jsulm
After building the project, nothing has changed -
@jsulm
After building the project, nothing has changed -
@JonB said in Error "file not found":
Do you have a
.pro
file for your project? Have you put into that which Qt modules your project will be using?@JonB said in Error "file not found":
Do you have a .pro file for your project? Have you put into that which Qt modules your project will be using?
.pro file is missing. Additional modules are not connected. An example of the program is taken from the finished blank when creating a new project.
-
@JonB said in Error "file not found":
Do you have a .pro file for your project? Have you put into that which Qt modules your project will be using?
.pro file is missing. Additional modules are not connected. An example of the program is taken from the finished blank when creating a new project.
@Nik_prog04 said in Error "file not found":
.pro file is missing
Are you using CMake then? Please help us help you...
-
@Nik_prog04 said in Error "file not found":
.pro file is missing
Are you using CMake then? Please help us help you...
@jsulm
Yes, Cmake is used, I just started learning and working with Qt, so I don't fully understand you. As I understand you mean file with name CMakeList.txt:cmake_minimum_required(VERSION 3.5) project(test_231022 VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) set(PROJECT_SOURCES main.cpp mainwindow.cpp mainwindow.h mainwindow.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(test_231022 MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: # set_property(TARGET test_231022 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) add_library(test_231022 SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() add_executable(test_231022 ${PROJECT_SOURCES} ) endif() endif() target_link_libraries(test_231022 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) set_target_properties(test_231022 PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) install(TARGETS test_231022 BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(test_231022) endif()
-
@jsulm
Yes, Cmake is used, I just started learning and working with Qt, so I don't fully understand you. As I understand you mean file with name CMakeList.txt:cmake_minimum_required(VERSION 3.5) project(test_231022 VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) set(PROJECT_SOURCES main.cpp mainwindow.cpp mainwindow.h mainwindow.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(test_231022 MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: # set_property(TARGET test_231022 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) add_library(test_231022 SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() add_executable(test_231022 ${PROJECT_SOURCES} ) endif() endif() target_link_libraries(test_231022 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) set_target_properties(test_231022 PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) install(TARGETS test_231022 BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(test_231022) endif()
@Nik_prog04 QMainWindow should be found.
Question: does your app build? -
@Nik_prog04 QMainWindow should be found.
Question: does your app build?@jsulm said in Error "file not found":
Question: does your app build?
Yes, there are no obvious errors in the build process. -
@jsulm said in Error "file not found":
Question: does your app build?
Yes, there are no obvious errors in the build process.@Nik_prog04 So, as I assumed at the beginning the problem is the code model used to analyse code in QtCreator. What QtCreator version do you use? I think there were bugs related to code model.
-
@Nik_prog04 So, as I assumed at the beginning the problem is the code model used to analyse code in QtCreator. What QtCreator version do you use? I think there were bugs related to code model.
@jsulm
6.4.0 -
@jsulm
6.4.0@Nik_prog04 This looks like Qt version
-
@jsulm
6.4.0@Nik_prog04 You can disable the Clang code model plug-in in QtCreator to get rid of these false positives.
-
@Nik_prog04 You can disable the Clang code model plug-in in QtCreator to get rid of these false positives.
@jsulm
Well, I'll try to do it. Thank you so much for your help