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. qt5 can't find widgets includes
Qt 6.11 is out! See what's new in the release blog

qt5 can't find widgets includes

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 4.1k Views 1 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.
  • peteriusP Offline
    peteriusP Offline
    peterius
    wrote on last edited by
    #1

    Hi,
    I've tried setting up Qt in a number of different ways and haven't gotten it working so far. I tried compiling from source with msys on windows 10 but I had a lot of difficulties. First, the srcbase didn't equal the outbase so I went into qtbase/bin/syncqt.pl and added $srcbase = $outbase several places, and then deleted all the header files in, I think include/QtCore.

    Then I got a bunch of "has not been declared" errors from
    c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\cstdlib:201:11: error: '::lldiv_t' has not been declared
    using ::lldiv_t;
    I think this is because c:\mingw\include isn't in the path somehow, but I don't know how to get it in the path. I tried adding -Ic:\mingw\include to the configure options but it didn't work. Note that I can compile a test file with #include <algorithm> fine.

    Then I gave up on compiling from source and used the installer. I also installed Qt on a gentoo setup, and then compiling a project can't find the widget include files. Both windows 10 from the installer with qtcreator or mingw, as well as the gentoo setup give errors like these on trying to compile a project:

    g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++0x -Wall -Wextra -frtti -fexceptions -mthreads -DUNICODE -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -Inetwork -Iaudio -Igtp -Igame_interfaces -Igame_tree -Iboard -Isgf -IC:/Qt/5.6/mingw49_32/include -IC:/Qt/5.6/mingw49_32/include/QtMultimedia -IC:/Qt/5.6/mingw49_32/include/QtWidgets -IC:/Qt/5.6/mingw49_32/include/QtGui -IC:/Qt/5.6/mingw49_32/include/QtANGLE -IC:/Qt/5.6/mingw49_32/include/QtNetwork -IC:/Qt/5.6/mingw49_32/include/QtCore -Idebug -I. -IC:/Qt/5.6/mingw49_32/mkspecs/win32-g++ -o objects/displayboard.o displayboard.cpp
    In file included from displayboard.h:26:0,
    from displayboard.cpp:23:
    board/board.h:40:1: error: expected class-name before '{' token
    {
    ^
    board/board.h:44:27: error: 'QGraphicsScene' has not been declared
    Board(QWidget *parent=0, QGraphicsScene *c=0 );

    Any help is appreciated, thanks.

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

      Hi and welcome to devnet,

      Did you add QT += widgets to your .pro file ?

      Since Qt 5., the widgets have their own module.

      If you need to update your .pro file, don't forget to re-run qmake before building your project.

      On a side note, if you want to build Qt on Windows with MinGW, you should rather use the version provided with the installer.

      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
      • peteriusP Offline
        peteriusP Offline
        peterius
        wrote on last edited by
        #3

        Sure enough, most of the trouble was qt5/qt4 stuff. I'm using this all over the place:
        #if QT_VERSION >= 0x050000
        #include <QtWidgets>
        #endif

        As for compiling qt, I was trying to compile from the git repositories.

        A last question, where are the QtCore.dll, etc., supposed to be? I ended up copying them into the application directory but that doesn't feel right.

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

          That's a nasty hack, you are using a module includes which means that you are pulling in every header of that module.

          The correct way is to drop the module part of the includes i.e. #include <QtGui/QWidget> becomes #include <QWidget>.

          Then adding QT += widgets to your .pro file will be enough.

          If you try to run your application from the explorer then you have to follow the deployment guide.

          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

          • Login

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