diff --git a/m4/ax_have_qt.m4 b/m4/ax_have_qt.m4
index f035a81852..b43f8c2387 100644
--- a/m4/ax_have_qt.m4
+++ b/m4/ax_have_qt.m4
@@ -74,6 +74,13 @@ AC_DEFUN([AX_HAVE_QT],
     [QT_QMAKE="$withval"],
     [QT_QMAKE="qmake"]
   )
+
+  AC_ARG_WITH(qt5-config,
+    [  --with-qt5-config=FILE   uses given qt configuration],
+    [QT_CONFIGURATION="$withval"], 
+    [QT_CONFIGURATION=""]
+  )
+  
   AC_MSG_CHECKING(for Qt)
   # If we have Qt5 or later in the path, we're golden
   ver=`$QT_QMAKE --version | grep -o "Qt version ."`
@@ -96,7 +103,11 @@ percent.target = %
 percent.commands = @echo -n "\$(\$(@))\ "
 QMAKE_EXTRA_TARGETS += percent
 EOF
-    $QT_QMAKE $am_have_qt_pro -o $am_have_qt_makefile
+    if test -z $QT_CONFIGURATION; then
+      $QT_QMAKE $am_have_qt_pro -o $am_have_qt_makefile
+    else
+      $QT_QMAKE $am_have_qt_pro -o $am_have_qt_makefile -qtconf $QT_CONFIGURATION
+    fi
     QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH`
     QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS`
     rm $am_have_qt_pro $am_have_qt_makefile
