QGraphicsScene::changed() 始终返回应用程序窗口大小的单个矩形

发布于 2024-10-16 06:04:27 字数 226 浏览 3 评论 0原文

在 Qt 4.7.1 Windows 应用程序中,连接到 QGraphicsScene::changed() 的插槽按预期触发,但脏区域计数始终为 1,并且我得到的矩形大小始终与我的应用程序窗口相同。我尝试调用 QGraphicsView::setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);但这没有帮助。

有没有办法告诉 Qt 只给我更改页面的区域?

In a Qt 4.7.1 Windows app, a slot that's connected to QGraphicsScene::changed() is fired as expected but the dirty region count is always 1 and the rect size I get is always the same as my app window. I tried calling QGraphicsView::setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); but that didn't help.

Is there a way to tell Qt to only give me the area(s) of the page that changed?

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

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

发布评论

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

评论(1

萌吟 2024-10-23 06:04:27

QGRaphicsView 中的更新与 QGraphicsScene 中的更新不同。视图的更新是由于需要重新绘制视图而引起的。无论是否改变场景。这典型的是窗口(调整大小)和视图更改(滚动)。场景的变化也会触发视图的更新。

场景的变化就是场景内容的变化。就像添加或删除项目、缩放或平移变换一样。这将发出 changed() 信号。显示该场景的所有视图也将自行更新以进行显示。

例如。滚动视图不会生成任何场景更新,因为场景中没有任何变化。场景中的item的paint()函数将被调用来重新绘制。但场景中不会发出 changed() 信号。

例如,如果您更改场景的比例,整个场景都会发生变化。除了整个重绘之外,场景还会发出 changed() 信号并指示整个场景已更改。但是如果你向场景中添加一个新项目,changed() 应该仅指示新项目的矩形。

如果你想知道场景的哪一部分需要重新绘制,除了调用 QGraphicsView::setViewportUpdateMode() 之外,你还需要为视图安装一个事件过滤器并检查 QEvent ::绘画。请注意,QPaintEvent 中的区域和矩形位于视图的本地坐标中,可能与场景不同。但是 QGraphicsView 有许多映射函数来进行转换。

An update in a QGRaphicsView is different from the one in a QGraphicsScene. Update in the view is caused by the need to repaint the view. With or without changing the scene. This typical is from window (resize) and view changes (scroll). An change in the scene will also trigger an update to the view.

A change in a scene is the change of the content of the scene. Like adding or removing a item, scaling or translating of the transformation. This will emit the changed() signal. All views displaying that scene will also update themselves for the display.

For example. Scrolling a view around will not generate any scene update since nothing in the scene changed. The paint() function of items in the scene will be called to repaint. But no changed() signal will be emitted from the scene.

If you changed the scale of the scene for instance, the whole scene changed. In addition to the whole repaint, the scene will emit changed() signal and indicates the whole scene changed. But if you add a new item to the scene, changed() should indicate only the rect of the new item.

If you want to know what part of the scene need to be repainted, in addition to calling QGraphicsView::setViewportUpdateMode(), you need to install a event filter to the view and check for QEvent::Paint. Note that the region and rect in QPaintEvent is in local coordinate of the view, which can be different from the scene. But QGraphicsView has many mapping functions to do the conversion.

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