Results 1 to 6 of 6

Thread: Clickable URL in QMessageBox?

  1. #1
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Clickable URL in QMessageBox?

    I would like to display a URL in a QMessageBox that can be clicked on to follow the link.

    Is there a way to do this? As an alternative, I could use another kind of dialog and check for the mouse hovering over the text to change the cursor, etc.

    I would very much appreciate it if someone has a solution that would save me a lot of time?

    Thanks,
    Martin

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Clickable URL in QMessageBox?

    You can use QLabel with QLabel::setOpenExternalLinks set to true

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Clickable URL in QMessageBox?

    Works for me:
    Qt Code:
    1. QMessageBox::about(0, "Trolltech", "<a href='http://www.trolltech.com'>Trolltech</a>");
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Nov 2009
    Location
    Paris/France
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Clickable URL in QMessageBox?

    Quote Originally Posted by jpn View Post
    Works for me:
    Qt Code:
    1. QMessageBox::about(0, "Trolltech", "<a href='http://www.trolltech.com'>Trolltech</a>");
    To copy to clipboard, switch view to plain text mode 
    I came here googling for this very same problem. I still can't click on links in ::about() box. The link appears as such (blue, underlined), but clicking on it doesnt open anything. I'm using Qt 4.5.3 on linux/gentoo, and i know the general 'open a link' stuff works from within Qt on other application (starts firefox on my computer)

    I did try exactly the line quoted here.

  5. #5
    Join Date
    Nov 2009
    Location
    Paris/France
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Clickable URL in QMessageBox?

    As of september 2011, with qt 4.7.4, I can confirm this example does not work.


    Added after 5 minutes:


    Actually, google can find other people wonderig about this. So I guess it's not a bug on my system
    Exemple:
    http://stackoverflow.com/questions/2...-a-gui-with-qt
    Last edited by orzel; 13th September 2011 at 15:34.

  6. #6
    Join Date
    Sep 2010
    Posts
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Clickable URL in QMessageBox?

    Actually it does seem to work just fine, but you have to set the text format for the message box. So you may have to do it yourself:

    Qt Code:
    1. QMessageBox msgBox(this);
    2. msgBox.setWindowTitle("Help / About");
    3. msgBox.setTextFormat(Qt::RichText); //this is what makes the links clickable
    4. msgBox.setText("<a href='mailto:someone@somewhere.com?Subject=My%20Subject>Email me</a>");
    5. msgBox.exec();
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to semajnosnibor for this useful post:

    frankiefrank (29th September 2012)

Similar Threads

  1. QMessageBox buttons appearance
    By yartov in forum Qt Programming
    Replies: 6
    Last Post: 26th June 2008, 01:36
  2. Replies: 2
    Last Post: 23rd May 2008, 13:22
  3. Display row Number in QMessageBox
    By arunvv in forum Newbie
    Replies: 6
    Last Post: 1st May 2008, 23:24
  4. Re: Help on QMessageBox
    By arunvv in forum Newbie
    Replies: 2
    Last Post: 25th March 2008, 23:45
  5. QMessageBox problem in Qtopia
    By jogeshwarakundi in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 8th February 2008, 09:22

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.