QHelpEngine
-
Hi, I'm actually trying to provide documentation inside one of my Qt application and I'm not able to make it working.
I have generate qhc and qch files using doxygen, and I'm able to load this file into Qt Assistant and browse all elements contained in the qhc file.
But now I'm trying to display this into a Qt Application using QHelpEngine, without success.
QHelpEngine is able to load the qhc file, butQHelpEngine::indexModel()
andQHelpEngine::contentModel()
are empty.Here is my code used to test it:
Widget::Widget(QWidget *parent) : QWidget(parent) { //* QFileInfo fileInfo("help.qhc"); if (fileInfo.exists()) { QHelpEngine* he = new QHelpEngine(fileInfo.absoluteFilePath()); qDebug() << "Setup data: " << he->setupData(); qDebug() << he->error(); qDebug() << fileInfo.absoluteFilePath(); QHelpContentWidget *contentWidget = he->contentWidget(); QHelpIndexWidget* indexWidget = he->indexWidget(); he->searchEngine()->queryWidget()->show(); he->searchEngine()->resultWidget()->show(); QSplitter* splitter = new QSplitter(); splitter->addWidget(contentWidget); splitter->addWidget(indexWidget); QHelpContentModel *contentModel = he->contentModel(); QHelpIndexModel* indexModel = he->indexModel(); contentWidget->setModel(contentModel); indexWidget->setModel(indexModel); qDebug() << "Content model count: " << contentModel->rowCount(); qDebug() << "Index model count: " << indexModel->rowCount(); QHBoxLayout *hl = new QHBoxLayout; hl->addWidget(splitter); setLayout(hl); } //... }
and the output:
Setup data: true "" "path_to_my_file/help.qhc" Content model count: 0 Index model count: 0
I cannot see what I'm missing here. Any help would be appreciated.
-
Hi,
Which version of Qt are you using ?
On which platform ? -
@Gojir4
I know nothing about this, but...Your code seems to be from old post https://forum.qt.io/topic/3880/qhelpengine-how-to , or maybe you got it from same source? Anyway, have you read through all the posts there seemingly describing your situation? Some claim to have got it working. Though I admit the final, unanswered post (https://forum.qt.io/topic/3880/qhelpengine-how-to/22) looks a lot like you..?
Or, does the code at https://github.com/srish/QtHelpManual/blob/master/main.cpp (a) work and (b) help you?
-
Hi @JonB ,
You are right, this is highly inspired from the old post about the same subject. But as I didn't find any solution I made a a new one .
Maybe I need to add the
HelpBrowser
class and make this connection as suggessted by your second link.QObject::connect(helpEngine->contentWidget(), SIGNAL(linkActivated(const QUrl &)), helpBrowser, SLOT(setSource(const QUrl &)));
But I have also checked my qhc file using the sample projet Context-Sensitive Help Example and it doens't seems to work too. So I guess ther is another issue.
I will check that tomorrow as I'm out of office now.
Thanks for your valuable input. -
@JonB said in QHelpEngine:
Or, does the code at https://github.com/srish/QtHelpManual/blob/master/main.cpp (a) work and (b) help you?
I tried this and it almost works. Almost because only the root link from the index view is working, then I have to use links from the content view to navigate. Links under the root item (children) are not working from the index view and clicking on them add error messages in output:
QFSFileEngine::open: No file name specified QTextBrowser: No document for qthelp://org.qt-project.examples.simpletextviewer/doc/./openfile.html
When using my own documentation .qhc file, nothing is displayed. So I definitely didn't catch the logic here. I guess I will stay with Doxygen for documentation.