QWebView 适合窗口宽度

发布于 2024-08-06 08:03:05 字数 190 浏览 5 评论 0原文

我正在使用 Qt 4.5 用 C++ 编写一个电子书查看器,使用 QWebView 对象呈现 html 文件。

有些html文件需要较高的窗口宽度,否则会出现水平滚动条,这很烦人,因此我想实现一个选项以使内容适合窗口宽度。

请问您知道如何使用 Qt 实现这一点吗?

这不是关于隐藏水平滚动条,而是关于“适合宽度”功能。

I'm writing an ebook viewer in C++ using Qt 4.5, using the QWebView object to render html files.

Some of the html files need a high window width, otherwise an horizontal scroll bar will appear, which is very annoying, thus I would like to implement an option to fit the content to the window width.

Please, do you have any idea how to make it possible using Qt ?

This is not about hiding the horizontal scrollbar, but about a "fit-to-width" feature.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

阳光下慵懒的猫 2024-08-13 08:03:05

这听起来像是网页本身布局的问题。

检查 CSS 中的宽度以及页面元素(例如图像)的宽度。

为此,我强烈建议在 Firefox 中查看页面,使用 Firebug 插件来检查元素。

This sounds like a problem with the layout of the web page itself.

Check widths in the CSS, and the width of page elements such as images.

For this, I'd strongly recommend viewing the page in Firefox, using the Firebug add-on to inspect elements.

绳情 2024-08-13 08:03:05

也许您可以查找检测页面何时横向溢出以创建水平滚动条的源代码,并从中获得一些想法?

Maybe you can look up the source code that detects when the page overflows width-wise to create the horizontal scroll bar and get some ideas from there?

狼亦尘 2024-08-13 08:03:05

您不能按原样执行此操作,但是在 QGraphicsScene 中添加 QWebView 小部件怎么样?使用方法QGraphicsScene::addWidget()

然后您可以使用QGraphicsView的缩放功能。

请参阅此链接:http://labs. trolltech.com/blogs/2007/11/22/widgets-on-the-canvas-integrated/ 并阅读 QGraphicsScene 的文档

You cannot do this as is, but what about adding the QWebView widget inside a QGraphicsScene? Use the method QGraphicsScene::addWidget().

Then you can use the zooming capabilities of the QGraphicsView.

See this link: http://labs.trolltech.com/blogs/2007/11/22/widgets-on-the-canvas-integrated/ and read the documentation for QGraphicsScene

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文