real time detection of typed urls: common approach?
In a richtext-editor, how to perform real time formatting of urls?
SOMEWHERE in the web there HAS be an example, but I can't find any.
Here is what I already can do:
detect the links (starting with http. or www.)
insertHtml with <a href=http://link>link</a>
QtextCharFormat setAnchorHref(link) seems not to work, because it creates a
<a href="www.bild.de">
that does nothing, if I manually enter
<a href="http://www.bild.de">
it works but this is the reason why I can't use setAnchorHref.
So the devil's in the detail and so here are some problems:
How do I keep the surrounding tags like <b> and such? Those i have set via
font.setBold(True)
cur.mergeCharFormat(cur.charFormat())
like the windows sticky notes: When you type a link and then a space, it
recognizes the space and removes the blue color. In my program, it keeps
the blue color style of a link.
If i perform actions with the QTextCursor for real time formating (after
each textChanged-Signal), it often crashes and I don't know, why. (Yes you
don't have a crystal ball, but read on)
Are there common tasks to achieve my goal? What would be a good commonly
used approach? I would like to know how this is done in such programs but
don't have the source. Please give me some advise or point to a working
example, this is so driving me nuts.
No comments:
Post a Comment