Howto在QString中存储HTML代码时,默认浏览器中打开HTML页面
Howto open html page in default browser, when html code is stored in QString
我的QT应用程序应打开 HTML页面(使用默认浏览器,例如IE)。此HTML代码存储在QString
中。
打开此"文件"的最佳方法是什么?
我只有内容? QTemporaryFile
是答案吗?还是可以更轻松地做到这一点?
QString content = "<html>...</html>";
?
QDesktopServices::openUrl(QUrl("..."));
qtemporaryfile方法是迄今为止完成任务的最简单的方法。
我看不到其他任何方法,然后使用ActiveQT进行一些" vodoo",如果有效。
最好的问候。
编辑:示例
QString htmlData; // your HTML data here
// The six Xs are actually required.
QTemporaryFile tmpFile( QLatin1String( "thefileXXXXXX.html" ) );
tmpFile.open();
QTextStream out( &tmpFile )
out << htmlData;
tmpFile.close();
QDesktopServives::openUrl( QUrl::fromLocalFile( tmpFile.fileName() ) );
相关文章:
- 为什么由服务器重新保留的HTML页面没有在浏览器中渲染
- 如何使用http:uri方案启动默认的Web浏览器并使用Shellexecute访问主页
- 如何配置要使用默认的HTML包装器构建的Emscripten目标
- C 通过套接字将压缩的HTML发送到浏览器
- 通过浏览器使用 Java/C 访问 HTML TextField 组件
- 以编程方式在默认浏览器中打开多个 URL
- 在C++构建器5中设置默认浏览器
- Howto在QString中存储HTML代码时,默认浏览器中打开HTML页面
- 获取默认浏览器用户代理
- 如何在后台打开默认浏览器并获取网页的源代码
- 用一些html从Qt中打开默认邮件应用程序
- 0x80070002尝试设置默认浏览器时
- 使用C++在浏览器中打开 HTML 文件
- 希望开发我自己的小C++浏览器,基本上可以显示HTML,Javascript和Flash,从哪里开始
- 损坏的HTML - 浏览器不会从我的网络服务器下载整个HTTP响应,CURL可以
- 尝试在 Windows 10 上获取默认 Web 浏览器路径失败
- 创建进程默认浏览器
- C++GUI Windows默认浏览器
- 默认浏览器正在打开WebView loadUrl(url)
- visual如何使用vc++ / c++获取默认浏览器的关闭事件