qtwidgetsglobals.h file not found
-
I am trying to install and use Qt6 on my system but have run into issues. Here's my setup:
OS: KDE Neon (Ubuntu-based) Processor: Intel i5, 5th generation RAM: 8 GB
I installed Qt6 using the following commands:
sudo apt update sudo apt install qt6-base-dev
I included all dependencies as prompted during installation. However, when I try to run any Qt6 applications using the new Zed IDE, i get an error, clang: In included file: 'QtWidgets/qtwidgetsglobal.h' file not found'. If I try using Qt Creator, it says, no kits are available
-
Maybe it's in a separate dev package? You should look what qt packages are available through apt on your system.
-
The file qtwidgetsglobal.h in is present
qt6/QtWidgets
directory; however, an error still occurs. The Qt installer is encountering a server error regardless of the server selected using the--server
option. -
@EuclidDivisionLemma said in qtwidgetsglobals.h file not found:
The Qt installer is encountering a server error regardless of the server selected using the --server option.
Earlier you said you are just fetching the distro's Qt via
apt
. So what is this about? -
I tried both the methods - APT and Qt Online installer.
-
@EuclidDivisionLemma
It might have helped if you had mentioned this. If you are trying to mix the distro's Qt and Qt downloaded from TQtC site I think that will just lead to confusion.@EuclidDivisionLemma said in qtwidgetsglobals.h file not found:
If I try using Qt Creator, it says, no kits are available
To the nest of my knowledge (unless someone says otherwise) this would be independent of whether or not you have or it finds any Qt stuff. Don't you need to start by installing/verifying you have Linux build tools like gcc, make etc., have you checked you have those? I would have thought that is what constitutes a kit.
Also in my plain Ubuntu (I don't know about KDE Neon) I have to fetch and install
qtcreator
package viaapt
too, you don't?However, when I try to run any Qt6 applications using the new Zed IDE, i get an error, clang: In included file: 'QtWidgets/qtwidgetsglobal.h' file not found'.
An error from clang would come either during editing or compiling. I don't see how you would get this when trying to run an application. If it's during editing (code completion) I would ignore this for now while you get to the stage where you can compile and then run your program.
-
@JonB The error doesn't occur during run-time. It's a compiler error. Also, I have all the necessary tools including CMake, GCC etc.
Initially, I tried installing Qt and Qt Creator on Windows and encountered a server error. Believing that it was a Windows-specific issue, I installed another OS. I thought KDE Neon would be providing all necessary Qt and KDE frameworks.
Besides, I don't believe this has anything to do with Qt. Because even with wxWidgets and gtkmm, clang throws an error, saying one file or the other in included file is not found.
-
Hi,
Which version of Neon did you install ?
Can you provide a minimal project to reproduce this behaviour ? -
Here's a minimal example
#include <qt6/QtWidgets/QApplication> #include <qt6/QtWidgets/QWidget> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.setWindowTitle("Basic Qt6 Window"); window.resize(400, 300); window.show(); return app.exec(); }
The error is:
In file included from /usr/include/x86_64-linux-gnu/qt6/QtWidgets/QApplication:1,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/qt6/QtWidgets/qapplication.h:7:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
7 | #include <QtWidgets/qtwidgetsglobal.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
KDE Neon (based on Ubuntu 22.04) -
@EuclidDivisionLemma said in qtwidgetsglobals.h file not found:
#include <qt6/QtWidgets/QApplication>
#include <qt6/QtWidgets/QWidget>You should not have to do this. It should just be
#include <QApplication> #include <QWidget>
Try that. If not, and the files exist, then your include path is wrong.
-
It doesn't work, the files are in /usr/include/qt6/QtWidgets
-
@EuclidDivisionLemma
Then I would expect you to ensure that your include path has/usr/include/qt6
....
You don't want be to writing code which specifies/relies on a certain path of includes.I don't know whether this relates to your
QtWidgets/qtwidgetsglobal.h: No such file or directory
or not. You say the file exists, we need to get the path right for it to look in. -
Oh sorry, it is
/usr/include/x86_64-linux-gnu/qt6/
. But even after including the full path, it doesn't work, the same qtwidgetsglobal.h error` -
@EuclidDivisionLemma
I would expect it to work if you have#include <QApplication>
, the directory/usr/include/x86_64-linux-gnu/qt6
is on your include path, and the file exists at/usr/include/x86_64-linux-gnu/qt6/QtWidgets/qtwidgetsglobal.h
. That's all I know. -
What do you mean by "the directory /usr/include/x86_64-linux-gnu/qt6 is on your include path". Do you mean PATH variable?
-
@EuclidDivisionLemma said in qtwidgetsglobals.h file not found:
Do you mean PATH variable?
No, in the include paths for the compiler. They are automatically added by CMake when you link against the Qt libraries.
So show your CMakeLists.txt -
No, I don't have CMakeLists.txt, but I used
-I
flag -
@EuclidDivisionLemma said in qtwidgetsglobals.h file not found:
No, I don't have CMakeLists.txt, but I used -I flag
So how do you compile with QtCrerator then? qmake?
-
QtCreator does't work in the first place. When I use Qt Creator, it says that there are no suitable kits found. I'm compiling using the new Zed IDE.
-
@EuclidDivisionLemma said in qtwidgetsglobals.h file not found:
I'm compiling using the new Zed IDE.
So you should ask them how to properly set up a project in there. Maybe they also support CMake or qmake - I don't know.
Or fix your kit settings in QtCreator: https://doc.qt.io/qtcreator/creator-targets.html -