QMessageBox has links inside and cannot be clicked… here is a solution to the problem.
QMessageBox has links inside and cannot be clicked
I’ve set textFormat
to Qt::RichText
, but the link is still unclickable.
QMessageBox msgBox(this);
msgBox.setWindowTitle(QApplication::applicationName()
+ " $VER " + QApplication::applicationVersion());
msgBox.setTextFormat(Qt::RichText); this is what makes the links clickable
msgBox.setText("<a href=\"google.com\">Google</a>");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
Is there any solution? Confirmed not to work with Qt 4.7.
Solution
It works under my Qt 4.7.4, although I had to modify your HTML
. Minimal example:
#include <QApplication>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMessageBox msgBox;
msgBox.setTextFormat(Qt::RichText); this is what makes the links clickable
msgBox.setText("<a href='http://google.com/'>Google</a>");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return app.exec();
}
If I use this, the browser tab opens and the following message ends up in my console:
Created new window in existing browser session.
If I use your msgBox.setText
I get the error:
gvfs-open: file:///tmp/b/google.com: error opening location: Error stating file '/tmp/b/google.com': No such file or directory