dai*_*isy 4 linux ubuntu qmessagebox qt4.7
我已经设置为textFormat,Qt::RichText但该链接仍然无法点击。
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();
Run Code Online (Sandbox Code Playgroud)
有什么解决办法吗?已确认不适用于 Qt 4.7。
它在我的 Qt 4.7.4 下工作,尽管我必须修改你的HTML. 最小的例子:
#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();
}
Run Code Online (Sandbox Code Playgroud)
如果我使用这个,浏览器选项卡将打开,并且以下消息最终出现在我的控制台中:
Created new window in existing browser session.
Run Code Online (Sandbox Code Playgroud)
如果我使用你的msgBox.setText我会收到错误:
gvfs-open: file:///tmp/b/google.com: error opening location: Error stating file '/tmp/b/google.com': No such file or directory
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5050 次 |
| 最近记录: |