I have a ready-made HTML file, if it is opened through a browser, then a normal web page
is displayed.
How can this HTML file
be opened via the QTextBrowser
widget so that structured information is also displayed in it as a web page
?
I've tried something like this:
QFile file("/home/alex/data.html");
if(!file.open(QIODevice::ReadOnly))
QMessageBox::information(nullptr,"info",file.errorString());
QTextStream in(&file);
ui->textBrowser->setHtml(in.readAll());
but it didn't work out.
CodePudding user response:
There are dedicated classes to display full webpages:
https://doc.qt.io/qt-5/qtwebengine-index.html
https://doc.qt.io/qt-5/qtwebengine-webenginewidgets-simplebrowser-example.html
In your case, QTextBrowser can "only" display rich text following HTML tags.