diff --git a/m4/check-qt.m4 b/m4/check-qt.m4
new file mode 100644
index 0000000000000000000000000000000000000000..d0842812c4606a0b7d6b5f2d84d45f0502731c53
--- /dev/null
+++ b/m4/check-qt.m4
@@ -0,0 +1,63 @@
+AC_DEFUN([ALBERT_CHECK_QT],
+[AC_ARG_WITH([qtdir],
+[  --with-qtdir=QTDIR     Attempt to use the QT toolkit located in QTDIR.
+                         Default: ${QTDIR}.],
+[case "$withval" in
+	yes)
+		;;
+	no)
+		AC_MSG_ERROR([Nope, we _need_ QT])
+		;;
+	*)
+		QTDIR=${withval}
+		;;
+esac],
+[for i in /usr/lib/qt3 /usr/qt/3; do
+	if test -d $i; then
+		QTDIR=$i
+		break
+	fi
+done
+])
+AC_LANG_PUSH([C++])
+ALBERT_CHECK_PACKAGE(Qt, qt-mt, ${QTDIR}/lib, ${X_LIBS} -lX11,
+                     qgl.h, ${QTDIR}/include, required)
+AC_LANG_POP
+dnl
+dnl check for QGLWidget
+dnl
+AC_CACHE_CHECK([whether class QGLWidget compiles and links],
+   [ac_cv_qglwidget_links],
+   [ac_cv_qglwidget_links=no
+    ac_save_LDFLAGS=${LDFLAGS}
+    LDFLAGS="${Qt_LIB} ${OpenGL_LIB} ${LDFLAGS}"
+    AC_LANG_PUSH([C++])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_QGL_H
+# include <qgl.h>
+#endif]],
+                                    [[QGLWidget qgl;]])],
+                    [ac_cv_qglwidget_links=yes],
+                    [AC_MSG_FAILURE([Unable to compile and link a "QGLWidget"])
+                   ])
+    AC_LANG_POP
+    LDFLAGS="${ac_save_LDFLAGS}"
+])
+dnl
+dnl the meta-object compiler
+dnl
+AC_ARG_WITH([moc],
+[  --with-moc=PATH_TO_MOC Path to the "moc" program. Default: ${QTDIR}/bin/],
+[case "$withval" in
+	yes)
+		;;
+	no)
+		AC_MSG_ERROR([Nope, we need moc])
+		;;
+	*)
+		MOCPATH=${withval}
+		;;
+esac],
+[MOCPATH=${QTDIR}/bin])
+AC_PATH_PROG([MOC], moc, , [$MOCPATH:$QTDIR/bin:$PATH])
+
+])