Below is the code for highlighting the selected text
Qt Code:
  1. findText(str);
  2. page()->setContentEditable(true);
  3. QColor m_Color;
  4. m_Color.setNamedColor(hcolorlist[index]);
  5. QString clrName = m_Color.name();
  6. QLatin1String cmd = QLatin1String("HiliteColor");
  7. QString js = QString(QLatin1String("document.execCommand(\"%1\",null, \"%2\")")).arg(cmd).arg(clrName);
  8. QVariant va = page()->mainFrame()->evaluateJavaScript(js);
  9. page()->setContentEditable(false);
To copy to clipboard, switch view to plain text mode 

"str" in the code is the selected word.

I want set border color and onclick() event for the selected word

I have heard that its possible using <span> tag. But not sure how to apply it here.
Is there anyother way, border and onclick() event could be implemented