view1->setCacheMode(QGraphicsView::CacheBackground); view1->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
时间: 2024-06-07 22:07:19 浏览: 13
这两行代码是用来设置 QGraphicsView 的缓存模式和视口更新模式的。
setCacheMode() 方法用来设置 QGraphicsView 的缓存模式,它接受一个 QGraphicsView::CacheMode 类型的参数。这个参数控制着 QGraphicsView 对场景的缓存方式,从而影响绘制性能。在这里,我们把缓存模式设置为 QGraphicsView::CacheBackground,这表示 QGraphicsView 只在需要时才会重绘背景,而不是每次都重绘。
setViewportUpdateMode() 方法用来设置 QGraphicsView 的视口更新模式,它接受一个 QGraphicsView::ViewportUpdateMode 类型的参数。这个参数控制着 QGraphicsView 在什么情况下更新视口,从而影响绘制性能。在这里,我们把视口更新模式设置为 QGraphicsView::BoundingRectViewportUpdate,这表示 QGraphicsView 只在视口的边界发生变化时才会更新视口,而不是每次都更新。这样可以提高绘制性能,特别是当场景比较大时。
相关问题
view = new QGraphicsView(ui->graphicsView); scene = new QGraphicsScene(ui->graphicsView); view->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);为什么这个在主函数里不能屏蔽缩略图
这段代码创建了一个名为`view`的`QGraphicsView`对象,以及一个名为`scene`的`QGraphicsScene`对象,并将`scene`设置为`view`的场景。`view->setViewportUpdateMode(QGraphicsView::NoViewportUpdate)`将视口更新模式设置为`QGraphicsView::NoViewportUpdate`,这意味着视口不会自动更新,需要手动调用`viewport()->update()`或`update()`函数来更新视口。
如果您想要屏蔽缩略图,可以尝试将`view`的`setViewportUpdateMode`设置为`QGraphicsView::SmartViewportUpdate`或`QGraphicsView::FullViewportUpdate`。这样可以使视口自动更新并显示所需的图形。
另外,如果您希望完全禁用缩略图,请使用以下代码:
```
view->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
view->setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, true);
view->setOptimizationFlag(QGraphicsView::DontSavePainterState, true);
view->setOptimizationFlag(QGraphicsView::DontAdjustForContents, true);
```
这将禁用所有优化标志,并完全禁用缩略图。
ui.graphSrc->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); ui.graphSrc->SetOriginalImage(2);是什么意思
这是一段 C++ 代码,其中包含两行语句。
第一行语句设置了 QGraphicsView 组件的视口更新模式为 FullViewportUpdate。这意味着当组件的视口大小发生变化时,整个视口都会被更新,而不是只更新发生变化的部分。这种更新模式比较耗费资源,但能够确保视口的显示效果始终正确。
第二行语句调用了 QGraphicsView 组件的 SetOriginalImage 方法,并传入参数 2。这个方法的作用是将组件显示的图像设置为指定编号的原始图像。具体来说,这里的 2 表示使用程序中预先定义的第二张原始图像。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)