+ Reply to Thread
Results 1 to 7 of 7

Thread: Hyperlink text in QLabel to open web browser

  1. #1
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Hyperlink text in QLabel to open web browser

    Hi all,

    I'm developing an about window. In this window I have some urls.

    For example, if my label has the text: "http://www.qtcentre.org" I want that when the user click in the label, the web browser opens with the specified url.

    What is the best way to perform this?

    Regards.

  2. #2
    Join Date
    May 2010
    Location
    Romania->Arad;
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Hyperlink text in QLabel to open web browser

    You can use openExternalLinks

  3. #3
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Hyperlink text in QLabel to open web browser

    Hi Zlatomir,

    I have set openExternalLinks, LinksAccessibleByMouse and LinksAccessibleByKeyboard to true, but nothing happen when I click over the QLabel.

    What's wrong?

    Regards.

  4. #4
    Join Date
    Jul 2010
    Posts
    41
    Thanks
    6
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hyperlink text in QLabel to open web browser

    Is it a link? I mean the text should be like this:
    Qt Code:
    1. QLabel label;
    2. label.openExternalLinks(true);
    3. label.setText("<a href=\"http://www.qtcentre.org\" />QtCentre</a>");
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Hyperlink text in QLabel to open web browser

    Hi srazi,

    I have used your code but nothing happens when I click over the label. Have you tested the code?

    Regards.

  6. #6
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Hyperlink text in QLabel to open web browser

    Did You set text format to Plain text on QLabel? If so change it to Auto / Rich text.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  7. #7

    Default Re: Hyperlink text in QLabel to open web browser

    hello world
    the right code is :
    QLabel label;
    label.openExternalLinks(true);
    label.setText("<a href=\"http://www.qtcentre.org\">QtCentre</a>");
    i tested and it's work

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 11th July 2011, 13:50
  2. Replies: 0
    Last Post: 17th March 2011, 04:17
  3. Open URL on Non Default Browser
    By sheeeng in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2009, 08:34
  4. How to open a browser ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 4th December 2006, 19:21
  5. open a browser
    By npc in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 11:23

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