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
Re: Clickable URL in QMessageBox?
You can use QLabel with QLabel::setOpenExternalLinks set to true :)
Re: Clickable URL in QMessageBox?
Works for me:
Code:
QMessageBox::about(0,
"Trolltech",
"<a href='http://www.trolltech.com'>Trolltech</a>");
Re: Clickable URL in QMessageBox?
Quote:
Originally Posted by
jpn
Works for me:
Code:
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.
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
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:
Code:
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%20Subject>Email me</a>");
msgBox.exec();