I only had this problem in a library and fixed with in the library's CMakesList.txt with: add_definitions(${Qt6Core_DEFINITIONS}
add_definitions(${Qt6Core_DEFINITIONS}