I would like to launch URLs from a QTextEdit widget. The URLs are custom styled. I have made a naive attempt:
Writing text to the QTextEdit:
Code:
bool Text::WriteText( const QStringRef& str, bool inurl ) // Text is "public QTextEdit", inurl is true if we are appending an URL { if( !str.isEmpty() ) { if( inurl ) { cf.setAnchorHref(str.toString()); mergeCurrentCharFormat(cf); } insertPlainText(str.toString()); } return true; }
mouse click (debugging version for now, launch iceweasel when it will work):
Code:
{ bool bb; if( event->buttons() == Qt::LeftButton ) { bb = url.isEmpty(); } }
Works ... almost. If I click a URL in the text window, the "url" string contains the URL. If I click another URL, I get another URL correctly. But if I click a non-URL text, I get the last URL clicked. Not acceptable. What am I doing wrong?
