PDA

View Full Version : Getting current anchor in QTextEdit



slash_blog
18th November 2010, 09:13
I am trying to create a rich text editor that will insert HTML links to websites etc. It is working fine except for when I select the text again and try to change the URL, I am not able to. Is there a way we can tell what is the HTML anchor at the current cursor location?

For e.g.

if the (text) cursor is currently anywhere between the Google word, or any part or whole of Google text is selected I want to get the existing URL so that it can be edited, instead of inserting a new URL altogether.




<a href="http://www.google.com/">Google</a>

tbscope
18th November 2010, 09:27
You have:
http://doc.qt.nokia.com/4.7/qtextedit.html#anchorAt
http://doc.qt.nokia.com/4.7/qtextcursor.html#anchor
http://doc.qt.nokia.com/4.7/qtextcharformat.html#anchorHref
http://doc.qt.nokia.com/4.7/qtextcharformat.html#anchorNames

You can also set user data for any text block.

slash_blog
18th November 2010, 11:53
http://doc.qt.nokia.com/4.7/qtextcharformat.html#anchorHref

is what I needed, thank you!