QtDataVisualization;三维点的数据传递。
Q3DScatter 选中事件(信号)
- Q3DScatter::selectedSeriesChanged(QScatter3DSeries *series)
此事件将选中点所在的series传出,也就是说传递的是被选中的series,而不是单独的点,所以在未丢失series选中状态的情况下,不会触发多次信号。
- selectedSeries : QScatter3DSeries* const
This property holds the selected series or null.
QScatter3DSeries 选中事件(信号)
- QScatter3DSeries::selectedItemChanged(int index)
此事件在选中三维点时将选中点的索引位置传出,当选中其他点时会重新触发该信号。
- selectedItem : int
This property holds the item that is selected in the series.
应用实现点击数据点获取数据点坐标等信息
声明一个QScatter3DSeries 指针,用来保存选中的series。
QScatter3DSeries *m_selectedSeries = nullptr;
Q3DScatter::selectedSeriesChanged(QScatter3DSeries *series)的槽函数触发时用m_selectedSeries 保存传递过来的seres。随后在QScatter3DSeries::selectedItemChanged(int index)的槽函数中利用index索引m_selectedSeries 中的被选中点,就可以拿去选中点的数据了。
connect(Q3DScatter对象指针, &Q3DScatter::selectedSeriesChanged, this, &槽函数所在类::on3Dscatter_selected);
connect(QScatter3DSeries对象指针, &QScatter3DSeries::selectedItemChanged, this, &槽函数所在类::on3Dseries_selected);
void 槽函数所在类::on3Dscatter_selected(QScatter3DSeries *series)
{
if (series == nullptr) {
return;
}
m_selectedSeries = series;
}
void 槽函数所在类::on3Dseries_selected(int index)
{
if (m_selectedSeries == nullptr) {
return;
}
double x = m_selectedSeries->dataProxy()->array()->at(index).x();
double y = m_selectedSeries->dataProxy()->array()->at(index).y();
cout << "Point(" << x << "," << y << ")" << endl;
}