PDA

View Full Version : Clickable URL in QMessageBox?



martinb0820
2nd December 2008, 20:55
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

aamer4yu
3rd December 2008, 04:39
You can use QLabel with QLabel::setOpenExternalLinks set to true :)

jpn
4th December 2008, 21:04
Works for me:


QMessageBox::about(0, "Trolltech", "<a href='http://www.trolltech.com'>Trolltech</a>");

orzel
29th November 2009, 07:04
Works for me:


QMessageBox::about(0, "Trolltech", "<a href='http://www.trolltech.com'>Trolltech</a>");


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.

orzel
13th September 2011, 15:34
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/2464838/an-about-message-box-for-a-gui-with-qt

semajnosnibor
23rd March 2012, 04:45
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:


QMessageBox msgBox(this);
msgBox.setWindowTitle("Help / About");
msgBox.setTextFormat(Qt::RichText); //this is what makes the links clickable
msgBox.setText("<a href='mailto:someone@somewhere.com?Subject=My%20Su bject>Email me</a>");
msgBox.exec();