本页内容

Q3DGraphsWidgetItem Class

Q3DGraphsWidgetItem 类为图表提供了一个窗口和渲染循环。更多内容...

头文件: #include <Q3DGraphsWidgetItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS GraphsWidgets)
target_link_libraries(mytarget PRIVATE Qt6::GraphsWidgets)
qmake: QT += graphswidgets
继承自: QObject
继承自:

Q3DBarsWidgetItem、Q3DScatterWidgetItem 以及Q3DSurfaceWidgetItem

属性

公共函数

virtual ~Q3DGraphsWidgetItem() override
QGraphsTheme *activeTheme() const
qsizetype addCustomItem(QCustom3DItem *item)
void addTheme(QGraphsTheme *theme)
float ambientLightStrength() const
qreal aspectRatio() const
QtGraphs3D::CameraPreset cameraPreset() const
QVector3D cameraTargetPosition() const
float cameraXRotation() const
float cameraYRotation() const
float cameraZoomLevel() const
void clearSelection()
int currentFps() const
QList<QCustom3DItem *> customItems() const
qreal cutoffMargin() const
void doPicking(QPoint point)
void doRayPicking(QVector3D origin, QVector3D direction)
QtGraphs3D::DragMode dragMode() const
QtGraphs3D::GridLineType gridLineType() const
bool hasSeries(QAbstract3DSeries *series) const
qreal horizontalAspectRatio() const
bool isOrthoProjection() const
bool isPanEnabled() const
bool isPolar() const
bool isRotationEnabled() const
bool isSelectionEnabled() const
bool isZoomAtTargetEnabled() const
bool isZoomEnabled() const
float labelMargin() const
QColor lightColor() const
float lightStrength() const
QLocale locale() const
qreal margin() const
float maxCameraXRotation() const
float maxCameraYRotation() const
float maxCameraZoomLevel() const
bool measureFps() const
float minCameraXRotation() const
float minCameraYRotation() const
float minCameraZoomLevel() const
int msaaSamples() const
QtGraphs3D::OptimizationHint optimizationHint() const
QVector3D queriedGraphPosition() const
float radialLabelOffset() const
void releaseCustomItem(QCustom3DItem *item)
void releaseTheme(QGraphsTheme *theme)
void removeCustomItem(QCustom3DItem *item)
void removeCustomItemAt(QVector3D position)
void removeCustomItems()
QSharedPointer<QQuickItemGrabResult> renderToImage(QSize imageSize = QSize()) const
Q3DScene *scene() const
QAbstract3DAxis *selectedAxis() const
QCustom3DItem *selectedCustomItem() const
qsizetype selectedCustomItemIndex() const
QtGraphs3D::ElementType selectedElement() const
int selectedLabelIndex() const
QtGraphs3D::SelectionFlags selectionMode() const
QtGraphs3D::ShadowQuality shadowQuality() const
float shadowStrength() const
QList<QGraphsTheme *> themes() const
QtGraphs3D::TransparencyTechnique transparencyTechnique() const
QQuickWidget *widget() const
bool wrapCameraXRotation() const
bool wrapCameraYRotation() const

公共槽位

void setActiveTheme(QGraphsTheme *activeTheme)
void setAmbientLightStrength(float newAmbientLightStrength)
void setAspectRatio(qreal ratio)
void setCameraPosition(float horizontal, float vertical, float zoom = 100.0f)
void setCameraPreset(QtGraphs3D::CameraPreset preset)
void setCameraTargetPosition(QVector3D target)
void setCameraXRotation(float rotation)
void setCameraYRotation(float rotation)
void setCameraZoomLevel(float level)
void setCutoffMargin(qreal margin)
void setDragMode(QtGraphs3D::DragMode newDragMode)
void setGridLineType(const QtGraphs3D::GridLineType &gridLineType)
void setHorizontalAspectRatio(qreal ratio)
void setLabelMargin(float margin)
void setLightColor(QColor newLightColor)
void setLightStrength(float newLightStrength)
void setLocale(const QLocale &locale)
void setMargin(qreal margin)
void setMaxCameraXRotation(float rotation)
void setMaxCameraYRotation(float rotation)
void setMaxCameraZoomLevel(float level)
void setMeasureFps(bool enable)
void setMinCameraXRotation(float rotation)
void setMinCameraYRotation(float rotation)
void setMinCameraZoomLevel(float level)
void setMsaaSamples(int samples)
void setOptimizationHint(QtGraphs3D::OptimizationHint hint)
void setOrthoProjection(bool enable)
(since 6.12) void setPanButton(Qt::MouseButtons button)
void setPanEnabled(bool enable)
void setPolar(bool enable)
void setRadialLabelOffset(float offset)
void setRotationEnabled(bool enable)
void setSelectionEnabled(bool enable)
void setSelectionMode(const QtGraphs3D::SelectionFlags &selectionMode)
void setShadowQuality(const QtGraphs3D::ShadowQuality &shadowQuality)
void setShadowStrength(float newShadowStrength)
void setTransparencyTechnique(QtGraphs3D::TransparencyTechnique technique)
void setWidget(QQuickWidget *widget)
void setWrapCameraXRotation(bool wrap)
void setWrapCameraYRotation(bool wrap)
void setZoomAtTargetEnabled(bool enable)
void setZoomEnabled(bool enable)

信号

void activeThemeChanged(QGraphsTheme*activeTheme)
void ambientLightStrengthChanged()
void aspectRatioChanged(qreal比例)
void cameraPresetChanged(QtGraphs3D::CameraPresetpreset)
void cameraTargetPositionChanged(QVector3D目标)
void cameraXRotationChanged(float旋转)
void cameraYRotationChanged(float旋转)
void cameraZoomLevelChanged(float缩放级别)
void currentFpsChanged(intfps)
void cutoffMarginChanged(qrealnewMargin)
void dragModeChanged(QtGraphs3D::DragModedragMode)
void gridLineTypeChanged()
void horizontalAspectRatioChanged(qrealratio)
void labelMarginChanged(floatmargin)
void lightColorChanged()
void lightStrengthChanged()
void localeChanged(const QLocale&locale)
void marginChanged(qrealmargin)
void maxCameraXRotationChanged(floatrotation)
void maxCameraYRotationChanged(float旋转)
void maxCameraZoomLevelChanged(float缩放级别)
void measureFpsChanged(boolenabled)
void minCameraXRotationChanged(float旋转角)
void minCameraYRotationChanged(floatrotation)
void minCameraZoomLevelChanged(float缩放级别)
void msaaSamplesChanged(int采样数)
void optimizationHintChanged(QtGraphs3D::OptimizationHinthint)
void orthoProjectionChanged(boolenabled)
void panEnabledChanged(boolenable)
void polarChanged(boolenabled)
void queriedGraphPositionChanged(QVector3D数据)
void radialLabelOffsetChanged(float偏移量)
void rotationEnabledChanged(boolenable)
void selectedElementChanged(QtGraphs3D::ElementType类型)
void selectionEnabledChanged(boolenable)
void selectionModeChanged(const QtGraphs3D::SelectionFlagsselectionMode)
void shadowQualityChanged(QtGraphs3D::ShadowQualityquality)
void shadowStrengthChanged()
void transparencyTechniqueChanged(QtGraphs3D::TransparencyTechnique技术)
void wrapCameraXRotationChanged(boolwrap)
void wrapCameraYRotationChanged(boolwrap)
void zoomAtTargetEnabledChanged(boolenable)
void zoomEnabledChanged(boolenable)

详细说明

该类继承自QWindow ,并为继承它的图提供渲染循环。

您通常无需直接使用该类,而应使用其子类之一。

在 `QSurfaceFormat` 中,多重采样默认处于关闭状态。要启用多重采样,请将自定义表面格式设置为默认表面格式。要获取自定义表面格式,请使用 `QQuick3D::idealSurfaceFormat()`。

另请参阅 Q3DBarsWidgetItem 、Q3DScatterWidgetItem 、Q3DSurfaceWidgetItem 以及Qt Graphs 中的 3D C++ 类。

属性文档

activeTheme : QGraphsTheme*

该属性存储图的当前主题。

将 `activeTheme ` 设置为图所使用的活动主题。该操作会隐式调用 `addTheme()` 方法,将主题的所有权转移至该图。

如果activeTheme 为 null,则会创建一个临时的默认主题。如果后续显式设置了任何主题,该临时主题将被销毁。即使在设置主题之后,仍可修改其属性,且修改会立即生效。

访问函数:

QGraphsTheme *activeTheme() const
void setActiveTheme(QGraphsTheme *activeTheme)

通知器信号:

void activeThemeChanged(QGraphsTheme *activeTheme)

ambientLightStrength : float

该属性控制整个图表的环境光强度。

该值决定了图表中颜色的显示效果——无论光源位置如何,颜色都能均匀且明亮地呈现。

该值必须介于0.0f 和1.0f 之间。

访问函数:

float ambientLightStrength() const
void setAmbientLightStrength(float newAmbientLightStrength)

通知信号:

void ambientLightStrengthChanged()

aspectRatio : qreal

该属性保存了图形缩放中水平平面上最长轴与y轴之间的比例。

默认值为2.0 。

注意: 对Q3DBarsWidgetItem无影响 。

访问函数:

qreal aspectRatio() const
void setAspectRatio(qreal ratio)

通知信号:

void aspectRatioChanged(qreal ratio)

另请参阅 horizontalAspectRatio 。

cameraPreset : QtGraphs3D::CameraPreset

摄像机当前使用的预设位置。该值可设置为 CameraPreset 枚举中的任意一个值。此属性可用于设置观察图形的预定义摄像机角度。

默认情况下,摄像机预设设置为CameraPreset::FrontLow 。

注意:若 已设置cameraXRotation 、cameraYRotation 或cameraZoomLevel 属性,或调用了setCustomCamera(),则该属性将返回CameraPreset::NoPreset,直到再次调用setCameraPreset()或将预设更改为其他值为止。

访问函数:

QtGraphs3D::CameraPreset cameraPreset() const
void setCameraPreset(QtGraphs3D::CameraPreset preset)

通知器信号:

void cameraPresetChanged(QtGraphs3D::CameraPreset preset)

cameraTargetPosition : QVector3D

该属性以向量或顶点的形式存储摄像机目标位置在3D空间中的坐标。

默认值为QVector3D(0.0, 0.0, 0.0) 。

有效的坐标值范围为-1.0...1.0 ,其中边界值表示相应轴范围的边界。超出此范围的任何值都会被限制在边界上。

访问函数:

QVector3D cameraTargetPosition() const
void setCameraTargetPosition(QVector3D target)

通知信号:

void cameraTargetPositionChanged(QVector3D target)

cameraXRotation : float

该属性存储了相机围绕目标点进行的X轴旋转角度(单位:度)。

访问函数:

float cameraXRotation() const
void setCameraXRotation(float rotation)

通知信号:

void cameraXRotationChanged(float rotation)

cameraYRotation : float

该属性存储了相机围绕目标点进行的 Y 轴旋转角度(单位为度)。

访问函数:

float cameraYRotation() const
void setCameraYRotation(float rotation)

通知信号:

void cameraYRotationChanged(float rotation)

cameraZoomLevel : float

该属性以百分比形式存储摄像机的变焦级别。

100.0f 的默认值表示相机中未设置任何缩放。该值受minCameraZoomLevel 和maxCameraZoomLevel 属性的限制。

访问函数:

float cameraZoomLevel() const
void setCameraZoomLevel(float level)

通知信号:

void cameraZoomLevelChanged(float zoomLevel)

另请参阅 minCameraZoomLevel 和maxCameraZoomLevel 。

[read-only] currentFps : int

该属性保存了过去一秒内的渲染结果。

当启用帧率(FPS)测量时,结果会存储在此只读属性中。在测量激活后,该值至少需要一秒钟才会更新。

访问函数:

int currentFps() const

通知信号:

void currentFpsChanged(int fps)

另请参阅 measureFps 。

[since 6.11] cutoffMargin : qreal

该属性存储用于确定轴限值之间间距以及图形元素被剔除的位置的数值。

注意:不 影响条形图。

该枚举在 Qt 6.11 中引入。

访问函数:

qreal cutoffMargin() const
void setCutoffMargin(qreal margin)

通知器信号:

void cutoffMarginChanged(qreal newMargin)

[since 6.12] dragMode : QtGraphs3D::DragMode

确定如何解释图形上的拖动事件,取值为QtGraphs3D::DragMode 枚举中的一个值。

默认值为QtGraphs3D::DragMode::Rotate 。

该枚举在 Qt 6.12 中引入。

访问函数:

QtGraphs3D::DragMode dragMode() const
void setDragMode(QtGraphs3D::DragMode newDragMode)

通知器信号:

void dragModeChanged(QtGraphs3D::DragMode dragMode)

另请参阅 panEnabled 。

gridLineType : QtGraphs3D::GridLineType

无论网格线类型是QtGraphs3D::GridLineType::Shader 还是QtGraphs3D::GridLineType::Geometry ,此属性均有效。

此值将影响所有网格线。

访问函数:

QtGraphs3D::GridLineType gridLineType() const
void setGridLineType(const QtGraphs3D::GridLineType &gridLineType)

通知信号:

void gridLineTypeChanged()

另请参阅 QtGraphs3D::GridLineType 。

horizontalAspectRatio : qreal

该属性存储了图形中 x 轴与 z 轴之间的缩放比例。

0.0 的值表示根据坐标轴范围自动缩放。默认值为0.0 。

此属性对Q3DBarsWidgetItem 无影响,后者通过barThickness 和barSpacing 属性处理水平面的缩放。极坐标图也会忽略此属性。

访问函数:

qreal horizontalAspectRatio() const
void setHorizontalAspectRatio(qreal ratio)

通知信号:

void horizontalAspectRatioChanged(qreal ratio)

另请参阅 aspectRatio 、polar 、Q3DBarsWidgetItem::barThickness 和Q3DBarsWidgetItem::barSpacing 。

labelMargin : float

此属性用于指定坐标轴标签的放置边距。

负值将标签放置在绘图区域内,而正值将标签放置在绘图区域外。当该值为负时,标签的自动旋转功能将被禁用。默认值为0.1

访问函数:

float labelMargin() const
void setLabelMargin(float margin)

通知信号:

void labelMarginChanged(float margin)

另请参阅 QAbstract3DAxis::labelAutoAngle 。

lightColor : QColor

该属性用于存储环境光和镜面光の色。

该值会影响在Q3DScene 中指定的光照。

访问函数:

QColor lightColor() const
void setLightColor(QColor newLightColor)

通知信号:

void lightColorChanged()

lightStrength : float

该属性存储整个图的镜面光强度。

该值必须在0.0f 和10.0f 之间。

该值会影响Q3DScene 中指定的光。

访问函数:

float lightStrength() const
void setLightStrength(float newLightStrength)

通知信号:

void lightStrengthChanged()

locale : QLocale

此属性用于存储格式化各种数字标签时所使用的区域设置。

默认值为"C" 区域设置。

访问函数:

QLocale locale() const
void setLocale(const QLocale &locale)

通知信号:

void localeChanged(const QLocale &locale)

另请参阅 QValue3DAxis::labelFormat 。

margin : qreal

该属性指定可绘制图形区域边缘与图形背景边缘之间留白的绝对值。

如果边距值为负数,则边距将自动确定,并可能根据数据系列中各数据点的大小以及图表类型而有所不同。如果图表的纵横比未从默认值进行更改,则该值将被解释为 y 轴范围的百分比。默认值为-1.0 。

注意:若 为散点图设置的 边距小于自动确定的边距,可能会导致图表边缘处的散点与图表背景重叠。

注意:在 散点图和表面图中 ,如果边距相对于坐标轴标签的大小较小,则会调整坐标轴边缘标签的位置,以避免与相邻坐标轴的边缘标签发生重叠。

访问函数:

qreal margin() const
void setMargin(qreal margin)

通知信号:

void marginChanged(qreal margin)

maxCameraXRotation : float

该属性存储了摄像机围绕目标点进行的X轴旋转的最大角度(单位为度)。默认值为180.0

访问函数:

float maxCameraXRotation() const
void setMaxCameraXRotation(float rotation)

通知信号:

void maxCameraXRotationChanged(float rotation)

maxCameraYRotation : float

该属性保存了摄像机围绕目标点进行的 Y 轴旋转的最大角度(单位为度)。默认值为90.0

访问函数:

float maxCameraYRotation() const
void setMaxCameraYRotation(float rotation)

通知信号:

void maxCameraYRotationChanged(float rotation)

maxCameraZoomLevel : float

该属性存储相机允许的最大变焦级别。

如果将最大级别设置为一个低于现有最小级别的新的值,则最小级别也会相应调整为新的最大级别。如果当前的cameraZoomLevel 超出了新的范围,它也会被相应调整。默认值为500.0f 。

访问函数:

float maxCameraZoomLevel() const
void setMaxCameraZoomLevel(float level)

通知器信号:

void maxCameraZoomLevelChanged(float zoomLevel)

另请参阅 cameraZoomLevel 和minCameraZoomLevel 。

measureFps : bool

该属性控制渲染是连续进行的,还是按需进行的。

如果true ,则渲染为连续模式,且currentFps 属性的值会随之更新。默认值为false 。

访问函数:

bool measureFps() const
void setMeasureFps(bool enable)

通知器信号:

void measureFpsChanged(bool enabled)

另请参阅 currentFps 。

minCameraXRotation : float

该属性存储摄像机绕目标点旋转的最小X轴旋转角度(单位为度)。默认值为-180.0

访问函数:

float minCameraXRotation() const
void setMinCameraXRotation(float rotation)

通知信号:

void minCameraXRotationChanged(float rotation)

minCameraYRotation : float

该属性存储了相机围绕目标点进行的 Y 轴旋转的最小角度(单位为度)。默认值为0.0

访问函数:

float minCameraYRotation() const
void setMinCameraYRotation(float rotation)

通知信号:

void minCameraYRotationChanged(float rotation)

minCameraZoomLevel : float

该属性用于指定允许的最小相机缩放级别。

如果将最小级别设置为高于现有最大级别的新值,则最大级别也会相应调整为新的最小级别。如果当前的变焦级别超出了新范围,也会进行相应调整。minCameraZoomLevel 不能设置为低于1.0f 。默认值为10.0f 。

访问函数:

float minCameraZoomLevel() const
void setMinCameraZoomLevel(float level)

通知信号:

void minCameraZoomLevelChanged(float zoomLevel)

另请参阅 cameraZoomLevel 和maxCameraZoomLevel 。

msaaSamples : int

该属性存储MSAA中使用的采样数。

将使用的 MSAA 采样数设置为samples 。采样数可以是 0、2、4 或 8。

访问函数:

int msaaSamples() const
void setMsaaSamples(int samples)

通知信号:

void msaaSamplesChanged(int samples)

optimizationHint : QtGraphs3D::OptimizationHint

指定渲染优化时使用默认模式还是传统模式。

默认模式采用实例化渲染,在大多数系统上能以最佳性能提供全功能集。静态模式可优化图的渲染,非常适合大型且数据不变的集合。但在数据动态变化和项目旋转时,其运行速度较慢。由于选择操作未经过优化,因此不建议在海量数据集上使用静态模式。 静态优化仅适用于散点图。传统模式会单独渲染图中的所有项目,不进行实例化。仅当默认模式无法正常工作时(即目标系统不支持实例化)才应使用该模式。默认值为QtGraphs3D::OptimizationHint::Default 。

注意:在 某些环境下 ,使用静态优化的大型图表可能无法渲染,因为所有项目都是通过单个绘制调用渲染的,而不同的图形驱动程序对每次调用的最大顶点数支持各不相同。这个问题主要出现在 32 位和 OpenGL ES2 平台上。 要解决此问题,请选择顶点数较少的元素网格,或使用点网格。

访问函数:

QtGraphs3D::OptimizationHint optimizationHint() const
void setOptimizationHint(QtGraphs3D::OptimizationHint hint)

通知器信号:

void optimizationHintChanged(QtGraphs3D::OptimizationHint hint)

另请参阅 QAbstract3DSeries::mesh 。

orthoProjection : bool

该属性用于指定是否使用正射投影来显示图形。

默认值为false 。

注意: 当设置为true 时,阴影 将被禁用。

访问函数:

bool isOrthoProjection() const
void setOrthoProjection(bool enable)

通知信号:

void orthoProjectionChanged(bool enabled)

另请参阅 QAbstract3DAxis::labelAutoAngle 。

[since 6.12] panEnabled : bool

该属性用于指定此输入处理程序是否允许平移图表。

默认值为true 。

该枚举类型在 Qt 6.12 中引入。

访问函数:

bool isPanEnabled() const
void setPanEnabled(bool enable)

通知器信号:

void panEnabledChanged(bool enable)

另请参阅 dragMode 和setPanButton()。

polar : bool

无论水平坐标轴是否转换为极坐标轴,此属性均保持不变。

如果true ,则x轴变为角度轴,z轴变为半径轴。条形图不支持极坐标模式。

默认值为false 。

访问函数:

bool isPolar() const
void setPolar(bool enable)

通知信号:

void polarChanged(bool enabled)

另请参阅 orthoProjection 和radialLabelOffset 。

[read-only] queriedGraphPosition : QVector3D

该属性存储了沿每个轴查询到的最新图坐标值。

此只读属性包含Q3DScene::graphPositionQuery 的查询结果。这些值已归一化到[-1, 1] 的范围内。如果查询的位置超出图表边界,则这些值不会反映实际位置,而是指示[-1, 1] 范围之外的未定义位置。在进行查询之前,该值将为未定义。

由于没有单一正确的 3D 坐标能与特定的屏幕位置完全对应,因此为了保持一致性,查询始终针对包围图表的不可见框体的内侧进行。

注意:条形图 仅允许在图表底边高度处查询位置,因此条形图的 y 值始终为零,且仅当屏幕位置包含图表底边时,才可进行有效查询。

访问函数:

QVector3D queriedGraphPosition() const

通知信号:

void queriedGraphPositionChanged(QVector3D data)

另请参阅 Q3DScene::graphPositionQuery 。

radialLabelOffset : float

该属性存储径向极坐标轴上轴标注的归一化水平偏移量。

值0.0 表示应将标签绘制在 0 角度的极坐标轴网格线旁。值1.0 表示标签应绘制在图表背景边缘的常规位置。默认值为1.0 。

如果polar 属性值为false ,则该属性将被忽略。

访问函数:

float radialLabelOffset() const
void setRadialLabelOffset(float offset)

通知信号:

void radialLabelOffsetChanged(float offset)

另请参阅 polar 。

rotationEnabled : bool

该属性用于指定此输入处理程序是否允许图形旋转。

默认值为true 。

访问函数:

bool isRotationEnabled() const
void setRotationEnabled(bool enable)

通知器信号:

void rotationEnabledChanged(bool enable)

[read-only] scene : Q3DScene* const

该属性保存了一个Q3DScene 指针,可用于操作场景并访问场景元素。

该属性为只读。

访问函数:

Q3DScene *scene() const

[read-only] selectedElement : QtGraphs3D::ElementType

该属性存储图中选中的元素。

该属性可用于查询所选元素的类型。该类型在图中进行新选择并发出selectedElementChanged 信号之前一直有效。

例如,该信号可用于实现自定义输入处理程序,具体示例请参见“图形库”中“Scatter Graph ”选项卡下的示例。

访问函数:

QtGraphs3D::ElementType selectedElement() const

通知信号:

void selectedElementChanged(QtGraphs3D::ElementType type)

另请参阅 selectedLabelIndex()、selectedAxis()、selectedCustomItemIndex()、selectedCustomItem()、Q3DBarsWidgetItem::selectedSeries()、Q3DScatterWidgetItem::selectedSeries()、Q3DSurfaceWidgetItem::selectedSeries(),以及Q3DScene::setSelectionQueryPosition()。

selectionEnabled : bool

该属性用于指定此输入处理程序是否允许从图中进行选择。

默认值为true 。

访问函数:

bool isSelectionEnabled() const
void setSelectionEnabled(bool enable)

通知器信号:

void selectionEnabledChanged(bool enable)

selectionMode : QtGraphs3D::SelectionFlags

项目选择模式。

`SelectionFlags` 的组合。默认值为 `Item`。不同类型的图支持不同的选择模式。

访问函数:

QtGraphs3D::SelectionFlags selectionMode() const
void setSelectionMode(const QtGraphs3D::SelectionFlags &selectionMode)

通知信号:

void selectionModeChanged(const QtGraphs3D::SelectionFlags selectionMode)

另请参见 QtGraphs3D::SelectionFlags 。

shadowQuality : QtGraphs3D::ShadowQuality

该属性用于指定阴影的质量。

ShadowQuality 枚举值之一。默认值为Medium 。

注意:如果 将阴影质量设置为某个级别失败,则会降低该级别,直到成功设置为止。每次发生更改时,都会发出shadowQualityChanged 信号。

访问函数:

QtGraphs3D::ShadowQuality shadowQuality() const
void setShadowQuality(const QtGraphs3D::ShadowQuality &shadowQuality)

通知信号:

void shadowQualityChanged(QtGraphs3D::ShadowQuality quality)

另请参阅 QtGraphs3D::ShadowQuality 。

shadowStrength : float

该属性控制整个图形的阴影强度。

数值越大,阴影越深。该值必须介于0.0 和100.0 之间。

该值会影响Q3DScene 中指定的光照效果。

访问函数:

float shadowStrength() const
void setShadowStrength(float newShadowStrength)

通知信号:

void shadowStrengthChanged()

[since 6.9] transparencyTechnique : QtGraphs3D::TransparencyTechnique

指定要使用的透明度处理方式。默认值为Default 。渲染透明曲面图时,请使用Approximate 或Accurate 。对于其他图类型,应使用Default 。

常量描述
Default表示不使用与顺序无关的透明度技术。可提供最佳性能。当图表不包含透明度,或者条形图或散点图同时使用实例化时(即optimizationHint 为 {QtGraphs3D::OptimizationHint::Default}),请使用此选项。
Approximate表示图将尝试近似实现顺序无关透明度。此方法比 `Accurate ` 更快,可在旧版硬件上运行,但可能会产生不准确的结果。当需要顺序无关透明度,但性能开销必须低于使用精确顺序无关透明度时,请使用此方法。
Accurate表示使用精确的顺序无关透明度。当需要完美的透明度渲染时使用。

此枚举在 Qt 6.9 中引入。

访问函数:

QtGraphs3D::TransparencyTechnique transparencyTechnique() const
void setTransparencyTechnique(QtGraphs3D::TransparencyTechnique technique)

通知器信号:

void transparencyTechniqueChanged(QtGraphs3D::TransparencyTechnique technique)

另请参阅 QtGraphs3D::TransparencyTechnique 。

wrapCameraXRotation : bool

该属性控制 X 轴旋转的最小值和最大值的行为。

若设置为true ,摄像机的X轴旋转将从最小值循环至最大值,再从最大值循环回最小值。若设置为false ,摄像机的X轴旋转将限定在由最小值和最大值确定的扇区内。默认设置为true 。

访问函数:

bool wrapCameraXRotation() const
void setWrapCameraXRotation(bool wrap)

通知信号:

void wrapCameraXRotationChanged(bool wrap)

wrapCameraYRotation : bool

此属性控制 Y 轴旋转的最小值和最大值限制的行为。

若true ,摄像机的Y轴旋转将从最小值循环至最大值,再从最大值循环至最小值。若false ,摄像机的Y轴旋转将限制在由最小值和最大值确定的扇区内。默认设置为true 。

访问函数:

bool wrapCameraYRotation() const
void setWrapCameraYRotation(bool wrap)

通知信号:

void wrapCameraYRotationChanged(bool wrap)

zoomAtTargetEnabled : bool

该属性用于控制缩放操作是否应更改相机目标,以便在缩放后,图表中被缩放的点仍保持在原位置。

默认值为true 。

访问函数:

bool isZoomAtTargetEnabled() const
void setZoomAtTargetEnabled(bool enable)

通知信号:

void zoomAtTargetEnabledChanged(bool enable)

zoomEnabled : bool

该属性用于指定此输入处理程序是否允许对图表进行缩放。

默认值为true 。

访问函数:

bool isZoomEnabled() const
void setZoomEnabled(bool enable)

通知信号:

void zoomEnabledChanged(bool enable)

成员函数文档

[override virtual noexcept] Q3DGraphsWidgetItem::~Q3DGraphsWidgetItem()

销毁Q3DGraphsWidgetItem 。

qsizetype Q3DGraphsWidgetItem::addCustomItem(QCustom3DItem *item)

向图中添加一个QCustom3DItem item 。图将拥有该添加项的所有权。

如果添加操作成功,则返回所添加项的索引;如果尝试添加空项,则返回 -1;如果尝试添加已存在的项,则返回该项的索引。

项目按插入顺序进行渲染。当存在实心和透明项目时,需考虑渲染顺序。

另请参阅 removeCustomItems()、removeCustomItem()、removeCustomItemAt() 以及customItems()。

void Q3DGraphsWidgetItem::addTheme(QGraphsTheme *theme)

将给定的theme 添加到图中。通过addTheme添加的主题不会被直接使用。仅将该主题的所有权赋予图。theme 不能为null,也不能已被添加到另一个图中。

另请参阅 releaseTheme() 和setActiveTheme()。

void Q3DGraphsWidgetItem::clearSelection()

清除所有关联系列中的选中项。

QList<QCustom3DItem *> Q3DGraphsWidgetItem::customItems() const

返回所有已添加的自定义项目的列表。

另请参阅 addCustomItem()。

void Q3DGraphsWidgetItem::doPicking(QPoint point)

使用来自point 的视图坐标对图中的元素进行点选操作,并选中第一个被击中的项目。默认的输入处理机制会在接收到 onTapped 事件时执行此操作。

另请参阅 selectedElement 。

void Q3DGraphsWidgetItem::doRayPicking(QVector3D origin, QVector3D direction)

从origin 开始,在direction 中对图的元素执行拣选操作,并选择第一个匹配的项目。

另请参阅 selectedElement 。

bool Q3DGraphsWidgetItem::hasSeries(QAbstract3DSeries *series) const

返回series 是否已添加到图中。

void Q3DGraphsWidgetItem::releaseCustomItem(QCustom3DItem *item)

获取给定item 的所有权,并将item 从图中移除。

注意:如果 将同一项重新添加到图形中,则需要重新设置纹理或纹理文件。

另请参阅 QCustom3DItem::setTextureImage() 和QCustom3DItem::setTextureFile()。

void Q3DGraphsWidgetItem::releaseTheme(QGraphsTheme *theme)

如果该theme 已被添加到此图中,则将其所有权交还给调用方。如果被释放的theme 正在使用中,系统将创建一个新的默认主题并将其设为活动状态。

如果默认主题已被释放,随后又被重新添加,其行为将与任何其他主题相同。

另请参阅 addTheme() 和setActiveTheme()。

void Q3DGraphsWidgetItem::removeCustomItem(QCustom3DItem *item)

删除自定义item 。并删除分配给它的资源。

void Q3DGraphsWidgetItem::removeCustomItemAt(QVector3D position)

删除position 下的所有自定义项目。并释放分配给这些项目的资源。

void Q3DGraphsWidgetItem::removeCustomItems()

删除所有自定义项目。并释放分配给这些项目的资源。

QSharedPointer<QQuickItemGrabResult> Q3DGraphsWidgetItem::renderToImage(QSize imageSize = QSize()) const

将当前帧渲染为imageSize 格式的图像。返回一个指向抓取结果的共享指针,该指针可在渲染完成的图像准备就绪后用于访问该图像。图像将按照当前的抗锯齿设置进行渲染。

另请参阅 QQuickItem::grabToImage()。

QAbstract3DAxis *Q3DGraphsWidgetItem::selectedAxis() const

可用于在接收到selectedElementChanged 信号(标签类型不限)后获取所选轴。该选择在收到下一个selectedElementChanged 信号之前一直有效。

返回所选轴的指针,或返回 null。

另请参阅 selectedElement 。

QCustom3DItem *Q3DGraphsWidgetItem::selectedCustomItem() const

可在接收到类型为 Q3DGraphsWidgetItem::ElementType::CustomItem 的selectedElementChanged 信号后,用于获取所选的自定义项。该项的所有权仍归图所有。选中状态有效直至下一个selectedElementChanged 信号触发。

返回所选自定义项的指针,或 null。

另请参阅 selectedElement 。

qsizetype Q3DGraphsWidgetItem::selectedCustomItemIndex() const

可在接收到类型为 Q3DGraphsWidgetItem::ElementType::CustomItem 的selectedElementChanged 信号后,用于查询所选自定义项的索引。该选择状态有效直至下一个selectedElementChanged 信号触发。

返回所选自定义项的索引,或 -1。

另请参阅 selectedElement 。

int Q3DGraphsWidgetItem::selectedLabelIndex() const

可在接收到selectedElementChanged 信号后,用于查询所选标签的索引,支持任何标签类型。该选择在接收到下一个selectedElementChanged 信号之前一直有效。

返回所选标签的索引,或 -1。

另请参阅 selectedElement 。

[slot] void Q3DGraphsWidgetItem::setCameraPosition(float horizontal, float vertical, float zoom = 100.0f)

用于设置摄像机旋转角度和距离的辅助函数。horizontal 和vertical 定义了要使用的摄像机旋转角度。可选参数zoom 用于在minCameraZoomLevel 和maxCameraZoomLevel 属性定义的范围内设置摄像机的缩放比例。

[slot, since 6.12] void Q3DGraphsWidgetItem::setPanButton(Qt::MouseButtons button)

设置用于触发 3D 图表平移操作的鼠标button 。

该函数于 Qt 6.12 中引入。

另请参阅 panEnabled 。

[slot] void Q3DGraphsWidgetItem::setWidget(QQuickWidget *widget)

将给定的widget 实例设置为该小部件项的QQuickWidget 。该图被设置为QQuickWidget 的内容。

图仅可在使用 QQuickWidgets 的控件应用程序中渲染。

用法示例:

QQuickWidget quickwidget;
Q3DBarsWidgetItem graph;
graph.setWidget(&quickwidget);

另请参阅 widget()。

QList<QGraphsTheme *> Q3DGraphsWidgetItem::themes() const

返回所有已添加主题的列表。

另请参阅 addTheme()。

QQuickWidget *Q3DGraphsWidgetItem::widget() const

返回指向已为该小部件项设置的QQuickWidget 实例的指针。

另请参阅 setWidget()。

© 2026 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.