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. Error "file not found"
Qt 6.11 is out! See what's new in the release blog

Error "file not found"

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 3 Posters 5.4k 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.
  • N Nik_prog04

    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.
    f723f8c0-2541-4ff8-bb1b-5afc720b9f0b-image.png

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

    @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?

    1 Reply Last reply
    0
    • N Nik_prog04

      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.
      f723f8c0-2541-4ff8-bb1b-5afc720b9f0b-image.png

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @Nik_prog04 Did you already build your project? QtCreator can show such errors until you build your project.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      JonBJ 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Nik_prog04 Did you already build your project? QtCreator can show such errors until you build your project.

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

        @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?

        jsulmJ 1 Reply Last reply
        0
        • JonBJ JonB

          @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?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #5

          @JonB Could be. But with this code model errors it is always a good idea to build and see whether they disappear :-)

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          1
          • N Offline
            N Offline
            Nik_prog04
            wrote on last edited by
            #6

            @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.

            jsulmJ JonBJ 2 Replies Last reply
            0
            • N Nik_prog04

              @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.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @Nik_prog04 Please show your pro file...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • N Nik_prog04

                @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.

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

                @Nik_prog04

                @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?

                N 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @JonB Could be. But with this code model errors it is always a good idea to build and see whether they disappear :-)

                  N Offline
                  N Offline
                  Nik_prog04
                  wrote on last edited by
                  #9

                  @jsulm
                  After building the project, nothing has changed

                  JonBJ 1 Reply Last reply
                  0
                  • N Nik_prog04

                    @jsulm
                    After building the project, nothing has changed

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

                    @Nik_prog04
                    Both @jsulm and I have asked you explicitly to show the context of your .pro file, else we won't be able to help. Is there any reason you have chosen not to do so and want people to guess?

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Nik_prog04

                      @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?

                      N Offline
                      N Offline
                      Nik_prog04
                      wrote on last edited by
                      #11

                      @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.

                      jsulmJ 1 Reply Last reply
                      0
                      • N Nik_prog04

                        @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.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        @Nik_prog04 said in Error "file not found":

                        .pro file is missing

                        Are you using CMake then? Please help us help you...

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        N 1 Reply Last reply
                        1
                        • jsulmJ jsulm

                          @Nik_prog04 said in Error "file not found":

                          .pro file is missing

                          Are you using CMake then? Please help us help you...

                          N Offline
                          N Offline
                          Nik_prog04
                          wrote on last edited by
                          #13

                          @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()
                          
                          jsulmJ 1 Reply Last reply
                          0
                          • N Nik_prog04

                            @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()
                            
                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @Nik_prog04 QMainWindow should be found.
                            Question: does your app build?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            N 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @Nik_prog04 QMainWindow should be found.
                              Question: does your app build?

                              N Offline
                              N Offline
                              Nik_prog04
                              wrote on last edited by
                              #15

                              @jsulm said in Error "file not found":

                              Question: does your app build?
                              Yes, there are no obvious errors in the build process.

                              jsulmJ 1 Reply Last reply
                              0
                              • N Nik_prog04

                                @jsulm said in Error "file not found":

                                Question: does your app build?
                                Yes, there are no obvious errors in the build process.

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                @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.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                N 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @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.

                                  N Offline
                                  N Offline
                                  Nik_prog04
                                  wrote on last edited by
                                  #17

                                  @jsulm
                                  6.4.0

                                  jsulmJ 2 Replies Last reply
                                  0
                                  • N Nik_prog04

                                    @jsulm
                                    6.4.0

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    @Nik_prog04 This looks like Qt version

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0
                                    • N Nik_prog04

                                      @jsulm
                                      6.4.0

                                      jsulmJ Offline
                                      jsulmJ Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      @Nik_prog04 You can disable the Clang code model plug-in in QtCreator to get rid of these false positives.

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      N 1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @Nik_prog04 You can disable the Clang code model plug-in in QtCreator to get rid of these false positives.

                                        N Offline
                                        N Offline
                                        Nik_prog04
                                        wrote on last edited by
                                        #20

                                        @jsulm
                                        Well, I'll try to do it. Thank you so much for your help

                                        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