title: real time detection of typed urls: common approach?
body: <p>In a richtext-editor, how to perform real time formatting of urls?</p>
  
  <p>SOMEWHERE in the web there HAS be an example, but I can't find any.</p>
  
  <p>Here is what I already can do:</p>
  
  <ul>
  <li><p>detect the links (starting with http. or www.)</p></li>
  <li><p>insertHtml with <code>&lt;a href=http://link&gt;link&lt;/a&gt;</code> </p></li>
  </ul>
  
  <p>QtextCharFormat setAnchorHref(link) seems not to work, because it creates a </p>
  
  <pre><code>&lt;a href="www.bild.de"&gt;
  </code></pre>
  
  <p>that does nothing, if I manually enter </p>
  
  <pre><code>&lt;a href="http://www.bild.de"&gt;
  </code></pre>
  
  <p>it works but this is the reason why I can't use setAnchorHref.</p>
  
  <p>So the devil's in the detail and so here are some problems:</p>
  
  <ul>
  <li><p>How do I keep the surrounding tags like <code>&lt;b&gt;</code> and such? Those i have set via </p>
  
  <pre><code>    font.setBold(True)
      cur.mergeCharFormat(cur.charFormat())
  </code></pre></li>
  <li><p>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.</p></li>
  <li><p>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)</p></li>
  </ul>
  
  <p>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.</p>