Qt开发总结(20)——Data Visualization

本文总结了Qt三维图表模块Data Visualization,包括三维柱状图、散点图和曲面图的使用,以及数据管理和代理。该模块适用于简单三维数据显示,基于Qt Graphics View架构,支持旋转、缩放和选中数据等操作。

上篇介绍了Qt Charts二维图表模块,本篇笔记总结Qt三维图表模块——Data Visualization。同样,在Qt5.7之前之后商业版才有,从Qt5.7开始免费开放在了社区版中。与QtCharts类似,也是基于Qt的Graphics View图形视图架构。当然,目前的Data Visualization还无法和一些专业的三维显示类库相提并论,但是对于一些简单的三维数据显示是比较实用的。另外,本人目前为止还未用过这个模块,所以文中不适当的地方请多包涵,也请评论区提宝贵意见。

概述

Data Visualization的三维显示功能主要由三种三维图形来实现,分别是三维柱状图Q3DBars,三维空间散点Q3DScatter,三维曲面Q3DSurface。这三个类的父类都是QAbstract3DGraph,从QWindow继承而来。

Data Visualization与Qt Charts类似都是基于Qt Graphics View的图形视图结构,所以一个三维图形也是由图表、序列、坐标轴等元素构成。响应的序列类有:QBar3DSeries,QScatter3DSeries,QSurface3DSeries类。这三个序列类是与图形类Q3DBars,Q3DScatter,Q3DSurface一一对应的。在一个图中可以有多个同类型的序列,但不能有不同类型的序列。另外,三维图形也有坐标轴类,共有两种坐标轴类:QValue3DAxis和QCategory3DAxis,前者用于数值型坐标轴,后者用于文字型坐标轴。

### 使用 Qt Maintenance Tool 安装 Qt Data Visualization Qt Maintenance Tool 是用于管理和维护 Qt 环境的强大工具,可以用来添加或删除模块、更新组件以及完全卸载环境。以下是关于如何通过该工具安装 `Qt Data Visualization` 组件的相关说明。 #### 工具功能概述 Qt Maintenance Tool 提供的功能包括但不限于以下几点[^1]: - **组件管理**:允许用户轻松添加或移除 Qt 模块(如 Android 支持、Qt Charts 和 Qt Data Visualization 等)。 - **更新机制**:能够将已安装的组件升级到最新版本。 - **卸载支持**:提供选项来彻底卸载整个 Qt 环境或者单独卸载某些组件。 #### 具体操作流程 为了安装 `Qt Data Visualization`,可以通过如下方式实现: 1. 打开 Qt Maintenance Tool 应用程序。 2. 登录账户并选择目标 Qt 版本对应的条目。 3. 转至 “Add or Remove Components” 页面,在列表中找到额外库分类下的 `Qt Data Visualization` 条目[^2]。 4. 勾选该项以准备安装,并点击继续按钮等待下载与配置过程结束即可完成部署工作。 如果之前仅安装了基础编译器而未包含可视化数据处理相关扩展,则按照上述方法补充所需插件是非常必要的[^3]。 ```python # 示例代码片段展示可能的应用场景之一——创建三维散点图 from PyQt5.QtDataVisualization import Q3DScatter, QScatterDataArray, QScatterDataItem def create_3d_scatter(): scatter = Q3DScatter() dataArray = QScatterDataArray() item = QScatterDataItem(QVector3D(0.5, 0.5, 0.5)) dataArray.append(item) scatter.seriesList()[0].dataProxy().addItems(dataArray) return scatter ``` 以上脚本展示了利用 PySide 或 PyQtQt Data Visualization 集成进 Python GUI 开发中的简单例子。
--------------------------- Qt Data Visualization 5.7.0 --------------------------- Qt Data Visualization module provides multiple graph types to visualize data in 3D space both with C++ and Qt Quick 2. System Requirements =================== - Qt 5.2.1 or newer - OpenGL 2.1 or newer (recommended) or OpenGL ES2 (reduced feature set) - Manipulating Qt Data Visualization graphs with QML Designer requires Qt Creator 3.3 or newer Building ======== Configure the project with qmake: qmake After running qmake, build the project with make: (Linux) make (Windows with MinGw) mingw32-make (Windows with Visual Studio) nmake (OS X) make The above generates the default makefiles for your configuration, which is typically the release build if you are using precompiled binary Qt distribution. To build both debug and release, or one specifically, use one of the following qmake lines instead. For debug builds: qmake CONFIG+=debug make or qmake CONFIG+=debug_and_release make debug For release builds: qmake CONFIG+=release make or qmake CONFIG+=debug_and_release make release For both builds (Windows/OS X only): qmake CONFIG+="debug_and_release build_all" make After building, install the module to your Qt directory: make install If you want to uninstall the module: make uninstall Building as a statically linked library ======================================= The same as above applies, you will just have to add static to the CONFIG: qmake CONFIG+=static Documentation ============= The documentation can be generated with: make docs The documentation is generated into the doc folder under the build folder. Both Qt Assistant (qtdatavisualization.qch) and in HTML format (qtdatavisualization subfolder) documentation is generated. Please refer to the generated documentation for more information: doc/qtdatavisualization/qtdatavisualization-index.html Known Issues ============ - Some platforms like Android and WinRT cannot handle multiple native windows properly, so only the Qt Quick 2 versions of graphs are available in practice for those platforms. - Shadows are not supported with OpenGL ES2 (including Angle builds in Windows). - Anti-aliasing doesn't work with OpenGL ES2 (including Angle builds in Windows). - QCustom3DVolume items are not supported with OpenGL ES2 (including Angle builds in Windows). - Surfaces with non-straight rows and columns do not always render properly. - Q3DLight class (and Light3D QML item) are currently not usable for anything. - Changing most of Q3DScene properties affecting subviewports currently has no effect. - Widget based examples layout incorrectly in iOS. - Reparenting a graph to an item in another QQuickWindow is not supported. - Android builds of QML applications importing QtDataVisualization also require "QT += datavisualization" in the pro file. This is because Qt Data Visualization QML plugin has a dependency to Qt Data Visualization C++ library, which Qt Creator doesn't automatically add to the deployment package. - Only OpenGL ES2 emulation is available for software renderer (that is, when using QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL))
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bjtuwayne

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值