0

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?

a1rltt
  • 3
  • 3

1 Answers1

0

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"));

Peter Kraume
  • 3,577
  • 2
  • 21
  • 39
  • When i write `QDesktopServices::openUrl(QUrl(QCoreApplication::applicationDirPath() + "/HELP.html#save"));`, i got an error _ShellExecute 'd:/ucheba/GPO/build-ReeGO-Desktop_Qt_5_13_2_MinGW_32_bit-Release/release/HELP.html#save' failed (error 2)._ When i write `QDesktopServices::openUrl(QUrl("file:///" + QCoreApplication::applicationDirPath() + "/HELP.html#save"));`, HTML is opening, but it ignores _#save_. Id is correct, when i use it for linking in browser, _#save_ appears in browser's line – a1rltt Jul 15 '20 at 07:37