QListView to open external links
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
Re: QListView to open external links
Re: QListView to open external links
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.
Re: QListView to open external links
Hi,
Thanks for your response. I actually thought about it but what if the list item has 2-3 links inside?
Re: QListView to open external links
How do you display the links?
Re: QListView to open external links
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).