Frage

How can I set an anchor in QTextEdit?

There seems to be a method to scroll to an anchor, but not any method to set actually one.

So I tried this, but it does not work.

mTextEdit->setHtml("some html stuff");
mTextEdit->append("<a href=\"#word\">word</a>");
mTextEdit->scrollToAnchor("word");

Any suggestions?

War es hilfreich?

Lösung

You have to give the name attribute to your anchor , like this:

mTextEdit->append("<a name=\"scrollToMe\" href=\"#word\">word</a>");

and then call the scrollToAnchor function:

mTextEdit->scrollToAnchor("scrollToMe");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top