Obsolete Members for QGraphicsScene
类QGraphicsScene 的以下成员已被弃用。提供这些成员是为了保持旧源代码的正常运行。我们强烈建议不要在新代码中使用它们。
保护函数
(deprecated) virtual void | drawItems(QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget = nullptr) |
成员函数文档
[virtual protected, deprecated]
void QGraphicsScene::drawItems(QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget = nullptr)
该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
在绘制背景后、前景前,使用提供的painter 绘制给定的items 。所有绘制都在场景坐标中完成。在绘制每个项目之前,必须使用QGraphicsItem::sceneTransform() 对绘制器进行转换。
options 参数是items 中每个项目的样式选项对象列表。numItems 参数是items 中的项目数和options 中的选项数。widget 参数为可选参数;如果指定,则应指向正在绘制的 widget。
默认实现会准备绘制矩阵,并在所有项目上调用QGraphicsItem::paint() 。重新实现此函数可为场景中的所有项目提供自定义绘制,从而完全控制每个项目的绘制方式。在某些情况下,这可以显著提高绘制性能。
举例说明:
void CustomScene::drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], QWidget *widget) { for (int i = 0; i < numItems; ++i) { // Draw the item painter->save(); painter->setTransform(items[i]->sceneTransform(), true); items[i]->paint(painter, &options[i], widget); painter->restore(); } }
自 Qt 4.6 起,除非将QGraphicsView::IndirectPainting 标志作为优化标志,否则将不再调用此函数。
另请参阅 drawBackground() 和drawForeground()。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.