Search code examples
c++qtqt-creatorqmakeqtwidgets

QtCreator Error: QGroupBox: No such file or directory


I've installed QtCreator 5.2.1 in Ubuntu and am trying to build and run an existing project that a coworker is working on. When I try to build the .pro file I receive an error "QGroupBox: No such file or directory.". I know this probably has something to do with the proper header files not being found (specifically QGroupBox.h) but am unsure how to remedy this. I've found the proper header files, so they exist on my system I just can't figure out how to get the IDE to acknowledge them. I'll also admit that I'm new to Linux so please bear with me...


Solution

  • You need to get the widgets module right as follows:

    QT += widgets
    

    If you wish to have your application supported by Qt 5 as well Qt 4, you would need to use the following:

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    

    But if you select a Widgets based application, it should have added it for you in the project file. Please double check that.

    By default, the QT variable only contains core and gui. That was fine for Qt 4 in this case because the widgets were covered by the QtGui. However, that changed in Qt 5 so that you get this class and the widgets in general from their separate widgets module.

    You can read more upon that here.