The Q3DScatter class provides methods for rendering 3D scatter graphs. 更多...
头: | #include <Q3DScatter> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
qmake: | QT += graphs |
继承: | QAbstract3DGraph |
状态: | 技术预览 |
Q3DScatter () | |
virtual | ~Q3DScatter () override |
void | addAxis (QValue3DAxis * axis ) |
void | addSeries (QScatter3DSeries * series ) |
QList<QValue3DAxis *> | axes () const |
QValue3DAxis * | axisX () const |
QValue3DAxis * | axisY () const |
QValue3DAxis * | axisZ () const |
void | releaseAxis (QValue3DAxis * axis ) |
void | removeSeries (QScatter3DSeries * series ) |
QScatter3DSeries * | selectedSeries () const |
QList<QScatter3DSeries *> | seriesList () const |
void | setAxisX (QValue3DAxis * axis ) |
void | setAxisY (QValue3DAxis * axis ) |
void | setAxisZ (QValue3DAxis * axis ) |
void | axisXChanged (QValue3DAxis * axis ) |
void | axisYChanged (QValue3DAxis * axis ) |
void | axisZChanged (QValue3DAxis * axis ) |
void | selectedSeriesChanged (QScatter3DSeries * series ) |
This class enables developers to render scatter graphs in 3D and to view them by rotating the scene freely. Rotation is done by holding down the right mouse button and moving the mouse. Zooming is done by mouse wheel. Selection, if enabled, is done by left mouse button. The scene can be reset to default camera view by clicking mouse wheel. In touch devices rotation is done by tap-and-move, selection by tap-and-hold and zoom by pinch.
If no axes are set explicitly to Q3DScatter, temporary default axes with no labels are created. These default axes can be modified via axis accessors, but as soon any axis is set explicitly for the orientation, the default axis for that orientation is destroyed.
Q3DScatter supports more than one series visible at the same time.
First, construct Q3DScatter. Since we are running the graph as top level window in this example, we need to clear the
Qt::FramelessWindowHint
flag, which gets set by default:
Q3DScatter scatter; scatter.setMinimumSize(QSize(256, 256));
Now Q3DScatter is ready to receive data to be rendered. Add one series of 3 QVector3D items:
QScatter3DSeries *series = new QScatter3DSeries; QScatterDataArray data; data << QScatterDataItem(0.5f, 0.5f, 0.5f) << QScatterDataItem(-0.3f, -0.5f, -0.4f) << QScatterDataItem(0.0f, -0.3f, 0.2f); series->dataProxy()->addItems(data); scatter.addSeries(series);
Finally you will need to set it visible:
scatter.show();
The complete code needed to create and display this graph is:
#include <QtGraphs> int main(int argc, char **argv) { QApplication app(argc, argv); Q3DScatter scatter; scatter.setMinimumSize(QSize(256, 256)); QScatter3DSeries *series = new QScatter3DSeries; QScatterDataArray data; data << QScatterDataItem(0.5f, 0.5f, 0.5f) << QScatterDataItem(-0.3f, -0.5f, -0.4f) << QScatterDataItem(0.0f, -0.3f, 0.2f); series->dataProxy()->addItems(data); scatter.addSeries(series); scatter.show(); return app.exec(); }
And this is what those few lines of code produce:
The scene can be rotated, zoomed into, and an item can be selected to view its position, but no other interaction is included in this minimal code example. You can learn more by familiarizing yourself with the examples provided, like the Simple Scatter Graph .
另请参阅 Q3DBars , Q3DSurface ,和 Qt Graphs C++ Classes for 3D .
This property holds the active x-axis.
设置 axis as the active x-axis. Implicitly calls addAxis () to transfer the ownership of the axis to this graph.
若 axis is null, a temporary default axis with no labels and an automatically adjusting range is created. This temporary axis is destroyed if another axis is set explicitly to the same orientation.
访问函数:
QValue3DAxis * | axisX () const |
void | setAxisX (QValue3DAxis * axis ) |
通知程序信号:
void | axisXChanged (QValue3DAxis * axis ) |
另请参阅 addAxis () 和 releaseAxis ().
This property holds the active y-axis.
设置 axis as the active y-axis. Implicitly calls addAxis () to transfer the ownership of the axis to this graph.
若 axis is null, a temporary default axis with no labels and an automatically adjusting range is created. This temporary axis is destroyed if another axis is set explicitly to the same orientation.
访问函数:
QValue3DAxis * | axisY () const |
void | setAxisY (QValue3DAxis * axis ) |
通知程序信号:
void | axisYChanged (QValue3DAxis * axis ) |
另请参阅 addAxis () 和 releaseAxis ().
This property holds the active z-axis.
设置 axis as the active z-axis. Implicitly calls addAxis () to transfer the ownership of the axis to this graph.
若 axis is null, a temporary default axis with no labels and an automatically adjusting range is created. This temporary axis is destroyed if another axis is set explicitly to the same orientation.
访问函数:
QValue3DAxis * | axisZ () const |
void | setAxisZ (QValue3DAxis * axis ) |
通知程序信号:
void | axisZChanged (QValue3DAxis * axis ) |
另请参阅 addAxis () 和 releaseAxis ().
[read-only]
selectedSeries
:
QScatter3DSeries
* const
This property holds the selected series or null.
访问函数:
QScatter3DSeries * | selectedSeries () const |
通知程序信号:
void | selectedSeriesChanged (QScatter3DSeries * series ) |
Constructs a new 3D scatter graph.
[override virtual noexcept]
Q3DScatter::
~Q3DScatter
()
Destroys the 3D scatter graph.
添加 axis to the graph. The axes added via addAxis are not yet taken to use, addAxis is simply used to give the ownership of the axis to the graph. The axis must not be null or added to another graph.
另请参阅 releaseAxis (), setAxisX (), setAxisY (),和 setAxisZ ().
添加 series to the graph. A graph can contain multiple series, but has only one set of axes. If the newly added series has specified a selected item, it will be highlighted and any existing selection will be cleared. Only one added series can have an active selection.
另请参阅 QAbstract3DGraph::hasSeries ().
Returns the list of all added axes.
另请参阅 addAxis ().
Releases the ownership of the axis back to the caller, if it is added to this graph. If the released axis is in use, a new default axis will be created and set active.
If the default axis is released and added back later, it behaves as any other axis would.
另请参阅 addAxis (), setAxisX (), setAxisY (),和 setAxisZ ().
移除 series from the graph.
另请参阅 QAbstract3DGraph::hasSeries ().
Returns the list of series added to this graph.
另请参阅 QAbstract3DGraph::hasSeries ().