It seems you're using CMake.
Check out the docs : Do you have
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
in your CMakeLists.txt
?
If you have this but still can't compile, the issue might be with your PATH variable.
Try reinstalling and / or manually adding your dependencies to your PATH if not done automatically. This blog post might help you.
To check your paths, try to set the debug option in CMake :
set(CMAKE_FIND_DEBUG_MODE 1)
find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
set(CMAKE_FIND_DEBUG_MODE 0)