Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QApplication: No such file or directory
Forum Updated to NodeBB v4.3 + New Features

QApplication: No such file or directory

Scheduled Pinned Locked Moved Solved Installation and Deployment
6 Posts 3 Posters 4.8k Views 2 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.
  • A Offline
    A Offline
    avnishsachar
    wrote on last edited by
    #1

    I have appropriately added QtWidgets to my CMakeLists.txt file but when I run make, it throws back the above-mentioned error. Everything works perfectly fine when I try the same with QGuiApplication though. Attaching the header file where I include QApplication (It works perfectly fine when I don't include QApplication). I don't understand where I am going wrong. Appreciate any help!

    #ifndef IGNITION_GUI_QT_H_
    #define IGNITION_GUI_QT_H_
    
    #ifndef _MSC_VER
    #pragma GCC system_header
    #endif
    
    #include <QtCore>
    #include <QtGui>
    
    #include <QGuiApplication>
    #include <QApplication>
    
    #include <QOffscreenSurface>
    #include <QOpenGLFunctions>
    
    #include <QQmlApplicationEngine>
    #include <QQmlComponent>
    #include <QQmlContext>
    #include <QQmlEngine>
    
    #include <QQuickItem>
    #include <QQuickStyle>
    #include <QQuickWindow>
    
    #include <QSGSimpleTextureNode>
    #include <QStandardItemModel>
    
    
    #endif  // IGNITION_GUI_QT_H_
    
    1 Reply Last reply
    1
    • A Offline
      A Offline
      avnishsachar
      wrote on last edited by
      #2

      There seems to be a problem with QtGui. As it cannot seem to locate QtGui either.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        What version of Qt ?
        What version of cmake ?
        How did you install both ?
        What OS ?
        What is the content of your CMakeList.txt ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          avnishsachar
          wrote on last edited by
          #4

          Hi, thanks for welcoming me!
          Apologies for not sharing the information in the post.
          Qt version 5.9.5
          cmake version 3.10.2
          I installed them using apt-get (used qt5-default)
          I'm running Ubuntu Bionic
          My CMakeLists.txt:

          include_directories(
            ${Qt5Core_INCLUDE_DIRS}
            ${Qt5Widgets_INCLUDE_DIRS}
            ${tinyxml_INCLUDE_DIRS}
            ${Qt5Qml_INCLUDE_DIRS}
            ${Qt5Quick_INCLUDE_DIRS}
            ${Qt5QuickControls2_INCLUDE_DIRS}
          )
          
          set (CMAKE_AUTOMOC ON)
          
          add_definitions(
            ${Qt5Core_DEFINITIONS}
            ${Qt5Widgets_DEFINITIONS}
            ${Qt5Qml_DEFINITIONS}
            ${Qt5Quick_DEFINITIONS}
            ${Qt5QuickControls2_DEFINITIONS}
          )
          
          set (qt_headers
            Application.hh
            Dialog.hh
            MainWindow.hh
            Plugin.hh
          )
          
          set (headers
            Conversions.hh
            DragDropModel.hh
            Enums.hh
            Helpers.hh
            ign.hh
            qt.h
            SearchModel.hh
            System.hh
          )
          
          set (resources resources.qrc)
          
          QT5_WRAP_CPP(headers_MOC ${qt_headers})
          QT5_ADD_RESOURCES(resources_RCC ${resources})
          
          ign_create_core_library(SOURCES
            ${sources}
            ${headers_MOC}
            ${resources_RCC}
            CXX_STANDARD 17
          )
          
          target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
            PUBLIC
              ${IGNITION-COMMON_LIBRARIES}
              ${IGNITION-MATH_LIBRARIES}
              ${IGNITION-MSGS_LIBRARIES}
              ignition-plugin${IGN_PLUGIN_VER}::loader
              ${IGNITION-TRANSPORT_LIBRARIES}
              ${Qt5Core_LIBRARIES}
              ${Qt5Widgets_LIBRARIES}
              ${Qt5Qml_LIBRARIES}
              ${Qt5Quick_LIBRARIES}
              ${Qt5QuickControls2_LIBRARIES}
              TINYXML2::TINYXML2
          )
          
          add_subdirectory(plugins)
          
          ign_install_all_headers(EXCLUDE_DIRS plugins)
          

          Please let me know in case more info. is needed. Thanks!

          1 Reply Last reply
          0
          • A Offline
            A Offline
            avnishsachar
            wrote on last edited by
            #5

            Solved the issue. I had not added Qt5Widgets to find_package in a top-level CMakeLists.txt.

            1 Reply Last reply
            3
            • A Offline
              A Offline
              ArantxaES
              wrote on last edited by
              #6

              I have the same issue but now with Qt6.

              • OS: Ubuntu 24.0.1
              • Qt: Creator 6.7.3
              • Compiler: gcc/g++ 13.2
              • IDE: MS Visual Studio Code (from snap)
              • Extensions installed in MVSC: ms-vscode.cpptools, twxs.cmake, ms-vscode.cmake-tools, theqtcompany.qt, theqtcompany.qt-cpp-pack and tonka3000.qtvsctools
              • Qt's installation folder: home/Qt/
              • Qt example's folder: home/Qt/Examples/Qt-6.7.3/widgets/widgets/calculator/

              I'm trying to run this example using CMakeLists.txt and c_cpp_properties.json.
              c_cpp_properties.json in .vscode:

              {
                  "configurations": [
                      {
                          "name": "Linux",
                          "includePath": [
                              "${workspaceFolder}/**",
                              "/home/arantxa/Qt/6.7.3/gcc_64/include/**",
                              "/home/arantxa/Qt/6.7.3/gcc_64/include/QtWidgets/"
                          ],
                          "defines": [],
                          "compilerPath": "/usr/bin/gcc",
                          "cStandard": "c17",
                          "cppStandard": "gnu++17",
                          "intelliSenseMode": "linux-gcc-x64"
                      }
                  ],
                  "version": 4
              }
              

              The top-level CMakeLists.txt:

              # Copyright (C) 2022 The Qt Company Ltd.
              # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
              
              cmake_minimum_required(VERSION 3.16)
              project(calculator LANGUAGES CXX)
              
              find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
              
              qt_standard_project_setup()
              
              qt_add_executable(calculator
                  button.cpp button.h
                  calculator.cpp calculator.h
                  main.cpp
              )
              
              set_target_properties(calculator PROPERTIES
                  WIN32_EXECUTABLE TRUE
                  MACOSX_BUNDLE TRUE
              )
              
              target_link_libraries(calculator PRIVATE
                  Qt6::Core
                  Qt6::Gui
                  Qt6::Widgets
              )
              
              install(TARGETS calculator
                  BUNDLE  DESTINATION .
                  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
                  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
              )
              
              qt_generate_deploy_app_script(
                  TARGET calculator
                  OUTPUT_SCRIPT deploy_script
                  NO_UNSUPPORTED_PLATFORM_ERROR
              )
              install(SCRIPT ${deploy_script})
              

              Everything that is required, every include, is listed! I'm not sure what should I do.

              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