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. QT can't find QWidget includes
Forum Update on Monday, May 27th 2025

QT can't find QWidget includes

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.6k 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.
  • R Offline
    R Offline
    R.griset
    wrote on 28 Nov 2019, 15:02 last edited by
    #1

    Hi, I'm trying to compile a project on Qt 5.7.1 on a debian distribution however qt can't find Widgets includes. When I checked to previous topics the answer always was to add QT+=Widgets in .pro file but it doesn't change anything on my side.

    I checked that I have the headers qt is looking for but the path is not added either in the .qmake.stash, nor in the Makefile generated.

    Here is a copy-paste of my .pro file :

    TEMPLATE = subdirs
    #CONFIG+=ordered
    QT += Widgets
    SUBDIRS =
    src
    app
    test \

    test.depends = src
    app.depends = src

    OTHER_FILES +=
    default.pri

    Any advices ?

    K 1 Reply Last reply 28 Nov 2019, 15:08
    0
    • R R.griset
      28 Nov 2019, 15:02

      Hi, I'm trying to compile a project on Qt 5.7.1 on a debian distribution however qt can't find Widgets includes. When I checked to previous topics the answer always was to add QT+=Widgets in .pro file but it doesn't change anything on my side.

      I checked that I have the headers qt is looking for but the path is not added either in the .qmake.stash, nor in the Makefile generated.

      Here is a copy-paste of my .pro file :

      TEMPLATE = subdirs
      #CONFIG+=ordered
      QT += Widgets
      SUBDIRS =
      src
      app
      test \

      test.depends = src
      app.depends = src

      OTHER_FILES +=
      default.pri

      Any advices ?

      K Offline
      K Offline
      KroMignon
      wrote on 28 Nov 2019, 15:08 last edited by KroMignon
      #2

      @R-griset Hmm, your PRO file seems to be a little strange to me, I would change it like this:

      TEMPLATE = subdirs
      #  You don't need widgets for a subdirs project!!!
      #QT += widgets
      
      # \ is used to continue on next line
      SUBDIRS = \
          src \
          app \
          test
      
      test.depends = src
      app.depends = src
      
      OTHER_FILES += default.pri
      

      I think this should work better, take a look at https://wiki.qt.io/SUBDIRS_-_handling_dependencies for more details.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      1
      • R Offline
        R Offline
        R.griset
        wrote on 28 Nov 2019, 16:22 last edited by
        #3

        Thanks for your answer, unfortunately I added "QT+=widgets" in order to solve an initial problem. Then here is initial errors when I try to compile with your .pro file :

        In file included from ../../UI_11_05/src/widgets/gantt_view.cpp:1:0:
        ../../UI_11_05/src/widgets/gantt_view.h:4:29: fatal error: QAbstractItemView: Aucun fichier ou dossier de ce type
        #include <QAbstractItemView>
        ^
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/resource_view.cpp:1:0:
        ../../UI_11_05/src/widgets/resource_view.h:4:29: fatal error: QAbstractItemView: Aucun fichier ou dossier de ce type
        #include <QAbstractItemView>
        ^
        In file included from ../../UI_11_05/src/widgets/central_widget_solution_tab.cpp:1:0:
        ../../UI_11_05/src/widgets/central_widget_solution_tab.h:4:21: fatal error: QComboBox: Aucun fichier ou dossier de ce type
        #include <QComboBox>
        ^
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/central_widget.cpp:1:0:
        ../../UI_11_05/src/widgets/central_widget.h:4:22: fatal error: QTabWidget: Aucun fichier ou dossier de ce type
        #include <QTabWidget>
        ^
        compilation terminated.
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/parameters_bar.cpp:1:0:
        ../../UI_11_05/src/widgets/parameters_bar.h:4:23: fatal error: QDockWidget: Aucun fichier ou dossier de ce type
        #include <QDockWidget>
        ^
        compilation terminated.
        /usr/lib/x86_64-linux-gnu/qt5/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I'/home/d07876/Bureau/Ancrage/Code interface graphique ancrage/UI_11_05/src' -I'/home/d07876/Bureau/Ancrage/Code interface graphique ancrage/UI_11_05/src' -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/include/c++/6 -I/usr/include/x86_64-linux-gnu/c++/6 -I/usr/include/c++/6/backward -I/usr/lib/gcc/x86_64-linux-gnu/6/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../../UI_11_05/src/widgets/sidebar.h -o moc_sidebar.cpp
        In file included from ../../UI_11_05/src/widgets/solution_pool_view.cpp:1:0:
        ../../UI_11_05/src/widgets/solution_pool_view.h:4:29: fatal error: QAbstractItemView: Aucun fichier ou dossier de ce type
        #include <QAbstractItemView>
        ^
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/mainwindow.cpp:1:0:
        ../../UI_11_05/src/widgets/mainwindow.h:4:24: fatal error: QApplication: Aucun fichier ou dossier de ce type
        #include <QApplication>
        ^
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/sidebar_list.cpp:1:0:
        ../../UI_11_05/src/widgets/sidebar_list.h:4:21: fatal error: QTreeView: Aucun fichier ou dossier de ce type
        #include <QTreeView>
        ^
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/sidebar.cpp:1:0:
        ../../UI_11_05/src/widgets/sidebar.h:4:23: fatal error: QDockWidget: Aucun fichier ou dossier de ce type
        #include <QDockWidget>
        ^
        compilation terminated.
        In file included from ../../UI_11_05/src/widgets/parameters_edition_dialog.cpp:1:0:
        ../../UI_11_05/src/widgets/parameters_edition_dialog.h:4:19: fatal error: QDialog: Aucun fichier ou dossier de ce type
        #include <QDialog>

        K 1 Reply Last reply 28 Nov 2019, 23:03
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 28 Nov 2019, 16:32 last edited by
          #4

          @R-griset said in QT can't find QWidget includes:

          Thanks for your answer, unfortunately I added "QT+=widgets" i

          You should add this line in the pro file in your subdirs where you're using widgets.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • R R.griset
            28 Nov 2019, 16:22

            Thanks for your answer, unfortunately I added "QT+=widgets" in order to solve an initial problem. Then here is initial errors when I try to compile with your .pro file :

            In file included from ../../UI_11_05/src/widgets/gantt_view.cpp:1:0:
            ../../UI_11_05/src/widgets/gantt_view.h:4:29: fatal error: QAbstractItemView: Aucun fichier ou dossier de ce type
            #include <QAbstractItemView>
            ^
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/resource_view.cpp:1:0:
            ../../UI_11_05/src/widgets/resource_view.h:4:29: fatal error: QAbstractItemView: Aucun fichier ou dossier de ce type
            #include <QAbstractItemView>
            ^
            In file included from ../../UI_11_05/src/widgets/central_widget_solution_tab.cpp:1:0:
            ../../UI_11_05/src/widgets/central_widget_solution_tab.h:4:21: fatal error: QComboBox: Aucun fichier ou dossier de ce type
            #include <QComboBox>
            ^
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/central_widget.cpp:1:0:
            ../../UI_11_05/src/widgets/central_widget.h:4:22: fatal error: QTabWidget: Aucun fichier ou dossier de ce type
            #include <QTabWidget>
            ^
            compilation terminated.
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/parameters_bar.cpp:1:0:
            ../../UI_11_05/src/widgets/parameters_bar.h:4:23: fatal error: QDockWidget: Aucun fichier ou dossier de ce type
            #include <QDockWidget>
            ^
            compilation terminated.
            /usr/lib/x86_64-linux-gnu/qt5/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I'/home/d07876/Bureau/Ancrage/Code interface graphique ancrage/UI_11_05/src' -I'/home/d07876/Bureau/Ancrage/Code interface graphique ancrage/UI_11_05/src' -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/include/c++/6 -I/usr/include/x86_64-linux-gnu/c++/6 -I/usr/include/c++/6/backward -I/usr/lib/gcc/x86_64-linux-gnu/6/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../../UI_11_05/src/widgets/sidebar.h -o moc_sidebar.cpp
            In file included from ../../UI_11_05/src/widgets/solution_pool_view.cpp:1:0:
            ../../UI_11_05/src/widgets/solution_pool_view.h:4:29: fatal error: QAbstractItemView: Aucun fichier ou dossier de ce type
            #include <QAbstractItemView>
            ^
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/mainwindow.cpp:1:0:
            ../../UI_11_05/src/widgets/mainwindow.h:4:24: fatal error: QApplication: Aucun fichier ou dossier de ce type
            #include <QApplication>
            ^
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/sidebar_list.cpp:1:0:
            ../../UI_11_05/src/widgets/sidebar_list.h:4:21: fatal error: QTreeView: Aucun fichier ou dossier de ce type
            #include <QTreeView>
            ^
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/sidebar.cpp:1:0:
            ../../UI_11_05/src/widgets/sidebar.h:4:23: fatal error: QDockWidget: Aucun fichier ou dossier de ce type
            #include <QDockWidget>
            ^
            compilation terminated.
            In file included from ../../UI_11_05/src/widgets/parameters_edition_dialog.cpp:1:0:
            ../../UI_11_05/src/widgets/parameters_edition_dialog.h:4:19: fatal error: QDialog: Aucun fichier ou dossier de ce type
            #include <QDialog>

            K Offline
            K Offline
            KroMignon
            wrote on 28 Nov 2019, 23:03 last edited by
            #5

            @R-griset I think you have misunderstood something, QT += widgets should be added in the application and library projects in which the widgets are used. Maybe the app project (app.pro)?

            It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

            1 Reply Last reply
            3
            • R Offline
              R Offline
              R.griset
              wrote on 29 Nov 2019, 08:31 last edited by
              #6

              Yes I didn't get it was in my app.pro file, unfortunately this line is already in this file, here is the app.pro file :

              include(../default.pri)

              QT += widgets

              QMAKE_CXXFLAGS += -std=c++0x

              QMAKE_LFLAGS_RPATH =
              QMAKE_LFLAGS = -Wl,-rpath,"'$$ORIGIN/../src'",--enable-new-dtags

              CONFIG -= app_bundle
              CONFIG += qtc_runnable
              #QT += serialport

              TEMPLATE = app

              SOURCES += main.cpp

              LIBS += -L../src -lmyapp

              jsulmJ 1 Reply Last reply 29 Nov 2019, 08:34
              0
              • R R.griset
                29 Nov 2019, 08:31

                Yes I didn't get it was in my app.pro file, unfortunately this line is already in this file, here is the app.pro file :

                include(../default.pri)

                QT += widgets

                QMAKE_CXXFLAGS += -std=c++0x

                QMAKE_LFLAGS_RPATH =
                QMAKE_LFLAGS = -Wl,-rpath,"'$$ORIGIN/../src'",--enable-new-dtags

                CONFIG -= app_bundle
                CONFIG += qtc_runnable
                #QT += serialport

                TEMPLATE = app

                SOURCES += main.cpp

                LIBS += -L../src -lmyapp

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on 29 Nov 2019, 08:34 last edited by
                #7

                @R-griset The errors seem to come from src subdirectory - did you add widgets there?

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

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  R.griset
                  wrote on 29 Nov 2019, 08:53 last edited by
                  #8

                  I noticed that just after my answer and indeed it solves this problem (still it doesn't compile but I need to check the new errors)
                  Thanks a lot for your help

                  C 1 Reply Last reply 29 Nov 2019, 11:15
                  0
                  • R R.griset
                    29 Nov 2019, 08:53

                    I noticed that just after my answer and indeed it solves this problem (still it doesn't compile but I need to check the new errors)
                    Thanks a lot for your help

                    C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 29 Nov 2019, 11:15 last edited by
                    #9

                    @R-griset The please mark this topic as solved, thx.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    1

                    1/9

                    28 Nov 2019, 15:02

                    • Login

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