diff --git a/libgui/src/documentation.cc b/libgui/src/documentation.cc
--- a/libgui/src/documentation.cc
+++ b/libgui/src/documentation.cc
@@ -627,33 +627,24 @@ namespace octave
   void documentation::selectAll (void) { }
 
   void documentation::load_ref (const QString& ref_name)
   {
     if (! m_help_engine || ref_name.isEmpty ())
       return;
 
     // First search in the function index
-#if defined (HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER)
-    QList<QHelpLink> found_links
-      = m_help_engine->documentsForIdentifier (ref_name);
-
-    QUrl first_url = found_links.constFirst().url;
-#else
     QMap<QString, QUrl> found_links
       = m_help_engine->linksForIdentifier (ref_name);
 
-    QUrl first_url = found_links.constBegin().value ();
-#endif
-
-      QTabWidget *navi = static_cast<QTabWidget*> (widget (0));
+    QTabWidget *navi = static_cast<QTabWidget*> (widget (0));
 
     if (found_links.count() > 0)
       {
-        m_doc_browser->setSource (first_url);
+        m_doc_browser->setSource (found_links.constBegin().value());
 
         // Switch to function index tab
         m_help_engine->indexWidget()->filterIndices (ref_name);
         QWidget *index_tab
           = navi->findChild<QWidget*> ("documentation_tab_index");
         navi->setCurrentWidget (index_tab);
       }
     else
diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -523,16 +523,51 @@ AC_DEFUN([OCTAVE_CHECK_FUNC_QHELPENGINE_
     AC_LANG_POP(C++)
   ])
   if test $octave_cv_func_qhelpengine_documentsforidentifier = yes; then
     AC_DEFINE(HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER, 1,
       [Define to 1 if you have the `QHelpEngine::documentsForIdentifier' member function.])
   fi
 ])
 dnl
+dnl Check whether the Qt class QHelpEngine has the documentsForIdentifier
+dnl function.  dnl This member function was introduced in Qt 5.15.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER], [
+  AC_CACHE_CHECK([for QHelpEngine::documentsForIdentifier in <QHelpEngine>],
+    [octave_cv_func_qhelpengine_documentsforidentifier],
+    [AC_LANG_PUSH(C++)
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    ac_octave_save_CXXFLAGS="$CXXFLAGS"
+    CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS"
+    CXXFLAGS="$CXXPICFLAG $CXXFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        #include <QHelpEngine>
+        #include <QHelpLink>
+        #include <QList>
+        #include <QString>
+        #include <QUrl>
+        ]], [[
+        QString collection_file;
+        QHelpEngine eng (collection_file);
+        QString id;
+        eng.documentsForIdentifier (id);
+        ]])],
+      octave_cv_func_qhelpengine_documentsforidentifier=yes,
+      octave_cv_func_qhelpengine_documentsforidentifier=no)
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    CXXFLAGS="$ac_octave_save_CXXFLAGS"
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_func_qhelpengine_documentsforidentifier = yes; then
+    AC_DEFINE(HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER, 1,
+      [Define to 1 if you have the `QHelpEngine::documentsForIdentifier' member function.])
+  fi
+])
+dnl
 dnl Check whether the Qt class QWheelEvent has the angleDelta member function.
 dnl This member function was introduced in Qt 5.
 dnl
 dnl FIXME: Delete this entirely when we drop support for Qt 4.
 dnl
 AC_DEFUN([OCTAVE_CHECK_FUNC_QWHEELEVENT_ANGLEDELTA], [
   AC_CACHE_CHECK([for QWheelEvent::angleDelta in <QWheelEvent>],
     [octave_cv_func_qwheelevent_angledelta],
@@ -2022,16 +2057,17 @@ AC_DEFUN([OCTAVE_CHECK_QT_VERSION], [AC_
     OCTAVE_CHECK_FUNC_QFONTMETRICS_HORIZONTAL_ADVANCE
     OCTAVE_CHECK_FUNC_QGUIAPPLICATION_SETDESKTOPFILENAME
     OCTAVE_CHECK_FUNC_QHELPSEARCHQUERYWIDGET_SEARCHINPUT
     OCTAVE_CHECK_NEW_QHELPINDEXWIDGET_API
     OCTAVE_CHECK_FUNC_QLIST_ITERATOR_CONSTRUCTOR
     OCTAVE_CHECK_FUNC_QSCREEN_DEVICEPIXELRATIO
     OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER
     OCTAVE_CHECK_FUNC_QWHEELEVENT_ANGLEDELTA
+    OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER
     OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION
 
     OCTAVE_CHECK_QREGION_ITERATORS
     OCTAVE_CHECK_QT_SPLITBEHAVIOR_ENUM
 
     if test -n "$OPENGL_LIBS"; then
       OCTAVE_CHECK_QT_OPENGL_OK([build_qt_graphics=yes],
         [warn_qt_opengl="Qt does not work with the OpenGL libs (GL and GLU); disabling OpenGL graphics with Qt GUI"])
