Qt 3D chart module -- Data Visualization learning record

Qt 3D chart module ----- Data Visualization
Qt data visualization module provides a method to visualize the data in 3D graphics into bar chart, scatter chart and surface chart. It is particularly useful for visualizing depth maps and large amounts of rapidly changing data, such as data received from multiple sensors. The look and feel of a drawing can be customized by using themes or adding custom items and labels.
QT data visualization is built on Qt5 and OpenGL to take advantage of hardware acceleration and QtQuick2.

If you intend to use Qt data visualization C + + classes in your application, use the following include and use directives:

 #include <QtDataVisualization>

  using namespace QtDataVisualization;

If you only use a few classes in this module, we recommend including only these specific classes, not the whole module.

To link to the Qt data visualization module, add this line to the qmake project file:

 QT += datavisualization

instructions:

3D histogram Q3DBars
Chart:
Sequence: QBar3DSeries
Coordinate axis: QValue3DAxis numerical coordinate axis,
QCategory3DAxis text axis

Data proxy class: QBarDataProxy class is the data proxy of 3D bar chart. The bar chart data agent handles adding, inserting, changing, and deleting data rows. The data array is the vector of the QBarDataItem instance (row) list. Each row can contain a different number of items or even empty. QBarDataProxy takes ownership of all QtDataVisualization:: QBarDataRow objects passed to it, either directly or in the QtDataVisualization:: QBarDataArray container. If you use the bar data row pointer to modify the data directly after adding the array to the proxy server , an appropriate signal must be sent to update the diagram.
QBarDataProxy can choose to track row and column labels. Q class 3DAxis can use these labels to display axis labels. Row and column labels and data are stored in a separate array, and the row operation method provides an alternative version that does not affect row labels. This allows you to choose to use row labels related to the position of the data in the array rather than the data itself.

A graph can have multiple sequences of the same series, but not different types of sequences.
Example:

#include <QtDataVisualization>

  using namespace QtDataVisualization;

  int main(int argc, char **argv)
  {
      QGuiApplication app(argc, argv);
//First, construct an instance of Q3DBars. Since the graph is run as a top-level window in this example, the Hint flag of Qt:: frame window needs to be cleared. The default setting is:
      Q3DBars bars;
      bars.setFlags(bars.flags() ^ Qt::FramelessWindowHint);
      //	//Sets the display range of the axis
      bars.rowAxis()->setRange(0, 4);
      bars.columnAxis()->setRange(0, 4);
      	//Create 5 rows of data, put them into the sequence and add them to the drawing
      QBar3DSeries *series = new QBar3DSeries;
      QBarDataRow *data = new QBarDataRow;
      *data << 1.0f << 3.0f << 7.5f << 5.0f << 2.2f;
      series->dataProxy()->addRow(data);
      bars.addSeries(series);
      bars.show();

      return app.exec();
  }

3D scatter chart Q3DScatter:
Chart:
Sequence: QScatter3DSeries
Coordinate axis: QValue3DAxis numerical coordinate axis,
QCategory3DAxis text axis

Data proxy class: the class corresponding to the sequence used to store the data of the sequence
QScatterDataProxy
A graph can have multiple sequences of the same series, but not different types of sequences.
Example:

#include <QtDataVisualization>

  using namespace QtDataVisualization;

  int main(int argc, char **argv)
  {
      QGuiApplication app(argc, argv);

      Q3DScatter scatter;
      scatter.setFlags(scatter.flags() ^ Qt::FramelessWindowHint);
      QScatter3DSeries *series = new QScatter3DSeries;
      QScatterDataArray data;
      data << QVector3D(0.5f, 0.5f, 0.5f) << QVector3D(-0.3f, -0.5f, -0.4f) << QVector3D(0.0f, -0.3f, 0.2f);
      series->dataProxy()->addItems(data);
      scatter.addSeries(series);
      scatter.show();

      return app.exec();
  }

3D surface Q3DSurface
Chart:
Sequence: QSurface3DSeries
Coordinate axis: QValue3DAxis numerical coordinate axis,
QCategory3DAxis text axis

Data proxy class: the class corresponding to the sequence used to store the data of the sequence
QSurfaceDataProxy
A graph can have multiple sequences of the same series, but not different types of sequences.

  #include <QtDataVisualization>

  using namespace QtDataVisualization;

  int main(int argc, char **argv)
  {
      QGuiApplication app(argc, argv);

      Q3DSurface surface;
      surface.setFlags(surface.flags() ^ Qt::FramelessWindowHint);
      QSurfaceDataArray *data = new QSurfaceDataArray;
      QSurfaceDataRow *dataRow1 = new QSurfaceDataRow;
      QSurfaceDataRow *dataRow2 = new QSurfaceDataRow;

      *dataRow1 << QVector3D(0.0f, 0.1f, 0.5f) << QVector3D(1.0f, 0.5f, 0.5f);
      *dataRow2 << QVector3D(0.0f, 1.8f, 1.0f) << QVector3D(1.0f, 1.2f, 1.0f);
      *data << dataRow1 << dataRow2;

      QSurface3DSeries *series = new QSurface3DSeries;
      series->dataProxy()->resetArray(data);
      surface.addSeries(series);
      surface.show();

      return app.exec();
  }

Keywords: Qt

Added by phpmoron on Fri, 17 Dec 2021 09:03:00 +0200