View Full Version : QListView to open external links

30th April 2014, 14:04
Hi all,

I have a chat program which I used QListView for the messaging view. I could update the status of message(IMDN) and display icons(by using QTextDocument) with no problem. But I'm facing with a problem now which concerns opening the links in the list view items.

I could successfully linkify the given text message and display it as a regular link(blue & underlined) but I'm not able to click on and open it yet. Is there a way to do this using QListView or any other methods?

Thanks in advance

30th April 2014, 23:48
Nothing yet?

1st May 2014, 02:26
Why don't you simply connect the clicked(const QModelIndex & index) signal of your QListView with a slot that opens the link at the clicked index?
For opening an url in the default browser use QDesktopServices::openUrl(const QUrl & url) method.

1st May 2014, 13:59

Thanks for your response. I actually thought about it but what if the list item has 2-3 links inside?

1st May 2014, 21:58
How do you display the links?

2nd May 2014, 12:46
I'm filtering the sent/received message with a QRegExp that analyzes all the links in the message and converted them to html links by covering them with "<a href...>the link</a>". Once I do this and add it the list view, links displayed as expected(blue & underlined).