Reputation: 730
I am trying to do as follows:
QWidget* helpWidget = new QWidget();
QHBoxLayout* layout = new QHBoxLayout();
QTextEdit* textEdit = new QTextEdit();
textEdit->loadResource(QTextDocument::HtmlResource, QUrl("qrc:/help.html"));
textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layout->addWidget(textEdit);
helpWidget->setLayout(layout);
The resource file is as follows:
<RCC>
<qresource prefix="/">
<file alias="help.html">../doc/index.html</file>
</qresource>
</RCC>
However the html file does not display in the QTextView. Can anyone help ?
Upvotes: 0
Views: 2574
Reputation: 4404
QTextEdit::loadResource
is a virtual method intended for a different purpose, see docs.
Instead you should manually read and set the HTML file contents:
QFile file(":/help.html");
file.open(QFile::ReadOnly | QFile::Text);
QTextStream stream(&file);
textEdit->setHtml(stream.readAll());
Upvotes: 4