QHelpEngineCore::documentsForKeyword() doesn't work
-
Hi there,
Qt documenation says following member function is obsolete:
https://doc.qt.io/qt-5/qhelpenginecore-obsolete.htmlQMap<QString, QUrl> QHelpEngineCore::linksForKeyword(const QString &keyword) const
and should be replaced by
QList<QHelpLink> QHelpEngineCore::documentsForKeyword(const QString &keyword) constI did that replacement. But whereas linksForKeyword(QString) works fine documentsForKeyword(QString) doesn't. Here my code:
// Qt version 5.15.0 // Compiler option: CONFIG += c++1z #include <QHelpEngine> #include <QMap> #include <QList> #include <QString> #include <QUrl> #include <QHelpLink> QString helpDoc = QApplication::applicationDirPath() + QString("MyHelpDocument.qhc"); QHelpEngine* helpEngine = new QHelpEngine(helpDoc); if (!helpEngine->setupData()) { // cleanup and return } QMap<QString, QUrl> links1 = helpEngine->linksForKeyword("MyKeyword"); // 1 link found QList<QHelpLink> links2 = helpEngine->documentsForKeyword("MyKeyword"); // 0 link found QList<QHelpLink> links3 = helpEngine->documentsForKeyword("MyKeyword", ""); // 0 link found // Using 'auto' for links.. declaration makes no difference
Why doesn't documentsForKeyword() find any link here?
-
Found it, you forgot to enable the new help engine: QHelpEngineCore::setUsesFilterEngine(true).
-
Hi,
Maybe you found an issue. Can you provide a minimal compilable example that shows your issue ?
-
Hi SGaist,
here's a minimal test application:
Dropbox downloadFor proper functioning shadow-build has to be disabled in Qt-Creator's build properties. Otherwise the application won't find the path to the help files.
If the download doesn't work or you need more files of the project please let me know.
-
@mireiner said in QHelpEngineCore::documentsForKeyword() doesn't work:
documentsForKeyword
You may have found something.You should check the bug report system to see if there's already something related. If not, then please open an new issue providing your minimal example. -
I don't think it's a Qt bug - QHelpCollectionHandler::linksForField() (the internal function called by QHelpEngineCore::linksForKeyword() ) is calling QHelpCollectionHandler::documentsForField() which is exactly what QHelpEngineCore::documentsForKeyword() is calling.
/edit: I'm looking at the current 5.15dev codebase. The change can be found here: https://codereview.qt-project.org/c/qt/qttools/+/291144
-
Found it, you forgot to enable the new help engine: QHelpEngineCore::setUsesFilterEngine(true).
-
@Christian-Ehrlicher said in QHelpEngineCore::documentsForKeyword() doesn't work:
Found it, you forgot to enable the new help engine: QHelpEngineCore::setUsesFilterEngine(true).
Hi Christian,
you're my hero - that really works. Never would have found this solution for my own.Now I wonder what the meaning of this "filter" is. Did not know that I was using a "filter" that had to be enabled by code.
Can you please lead me to the part of the Qt help documentation where the "filter" is fully explained?
Thank you very much for your help!
-
@mireiner said in QHelpEngineCore::documentsForKeyword() doesn't work:
Can you please lead me to the part of the Qt help documentation where the "filter" is fully explained?
This one? https://doc.qt.io/qt-5/qhelpenginecore.html#details
-
@Christian-Ehrlicher said in QHelpEngineCore::documentsForKeyword() doesn't work:
This one? https://doc.qt.io/qt-5/qhelpenginecore.html#details
Thanks for the help link. I have to read over the whole help documention again more carefully. The filter might be also implemented in the help project file *.qhp.
-
@Christian-Ehrlicher good catch ! I have missed that line.
I think it deserves a more prominent styling. I'll see to improve that.