How to fix "qwidgetsglobal.h not found"

32 Views Asked by At

When I compile a C++ program With Qt5 on ZorinOS 17 (it's an Ubuntu based Linux distro), I get this error:

In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QApplication:1,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/qt5/QtWidgets/qapplication.h:43:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
   43 | #include <QtWidgets/qtwidgetsglobal.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I installed Qt5 by manually installing all the necessary Qt modules using apt (I did this because there was no qt5-default package), this error also happens with Qt6.

#include <qt5/QtWidgets/QApplication>
#include <qt5/QtWidgets/QPushButton>

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    // Create a QPushButton with the label "Click Me!"
    QPushButton button("Click Me!");

    // Connect the button's clicked signal to the slot handling the click event
    QObject::connect(&button, &QPushButton::clicked, [&]() {
        // Slot code - executed when the button is clicked
        qDebug("Button Clicked!");
    });

    // Set up the main window
    button.show();

    // Start the application event loop
    return app.exec();
}

I tried using apt to see if there was an apt package related to qwidgetsglobal, but there wasn't. Originally I tried using Qt6, that didn't work.

On Windows when I was using MSYS2 Mingw-w64, I wanted to try Qt6, it did not work, but Qt5 worked, So I tried Qt5 on ZorinOS, and that still didn't work.

0

There are 0 best solutions below