Results 1 to 6 of 6

Thread: QListView to open external links

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default 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

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QListView to open external links

    Nothing yet?

  3. #3
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default 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:penUrl(const QUrl & url) method.

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default 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?

  5. #5
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QListView to open external links

    How do you display the links?

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default 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).

Similar Threads

  1. About Qt and external libraries... Tutorials? Links?
    By tonnot in forum General Programming
    Replies: 3
    Last Post: 12th January 2011, 01:30
  2. Replies: 1
    Last Post: 27th September 2010, 15:21
  3. HTML and *clickable links* inside a QListView?
    By Garibaldi in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2008, 11:44
  4. How to Open External Links?
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2008, 07:47
  5. open an external links
    By sudheer in forum Qt Tools
    Replies: 4
    Last Post: 17th January 2008, 05:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.