--- a/gecode.m4
+++ b/gecode.m4
@@ -1278,16 +1278,8 @@
     AS_HELP_STRING([--enable-qt],
       [build with Qt support, requires Qt 5.15 or newer @<:@default=yes@:>@]))
   AC_CHECK_PROGS(QMAKE, [qmake6 qmake-qt6 qmake-qt5 qmake5 qmake])
-  AC_CHECK_PROGS(MOC, [moc-qt6 moc6 moc-qt5 moc])
-  if test "${MOC}x" = "x" -a "${QMAKE}x" != "x"; then
-    for ac_gecode_qt_tool_dir in `${QMAKE} -query QT_INSTALL_LIBEXECS 2>/dev/null` `${QMAKE} -query QT_INSTALL_BINS 2>/dev/null`; do
-      for ac_gecode_moc_name in moc moc6 moc-qt6 moc-qt5; do
-        if test "${MOC}x" = "x" -a -x "${ac_gecode_qt_tool_dir}/${ac_gecode_moc_name}"; then
-          MOC="${ac_gecode_qt_tool_dir}/${ac_gecode_moc_name}"
-        fi
-      done
-    done
-  fi
+  MOC=/usr/lib/qt6/libexec/moc
+  AC_CHECK_PROGS(MOC, [/usr/lib/qt6/libexec/moc])
   AC_MSG_CHECKING(whether to build with Qt support)
   if test "${enable_qt:-yes}" = "yes"; then
     if test "${QMAKE}x" = "x" -o "${MOC}x" = "x"; then
--- a/Makefile.in
+++ b/Makefile.in
@@ -62,7 +62,7 @@
 
 export CXX = @CXX@
 export CC = @CC@
-export MOC = @MOC@
+export MOC = /usr/lib/qt6/libexec/moc
 ifeq "$(top_srcdir)" "$(top_builddir)"
 CPPFLAGS=-I$(top_srcdir)
 else
