How can i open HTML file on a specific header in QT?

170 Views Asked by At

I use help button (from QDialog) to open an HTML file, but i want it to open on specific header (<h1>, <h2>, etc.), depending on from which window i use help button.

This is how i open HTML:

QDesktopServices::openUrl(QUrl(QCoreApplication::applicationDirPath() + "/HELP.html"));

How can i do it?

1

There are 1 best solutions below

1
Peter Kraume On

When you add id attributes to your headlines, you can use anchor links:

<h1 id="somename">my headline</h1>

Your link can then look like this:

QDesktopServices::openUrl(QUrl(QCoreApplication::applicationDirPath() + "/HELP.html#somename"));