Unsolved Q3DSurface selected point signal
-
I am using QtDataVisualization (Q3DSurface in particular) to make a simple 3D surface graph.
The Q3DSurface supports selection of a point on the graph by showing a highlighted ball on the data point where the user has clicked. The selection pointer shows the coordinates of the point. It looks like this: surface with selected point
However, I'm not able to find a signal that is emitted when the selection happens. Having read through the documentation of Q3DSurface and QSurface3DSeries, I failed to find any corresponding signal. There is only a
selectedPointChanged(const QPoint &position)
in QSurface3DSeries, but it operates with a two-dimensional QPoint which is not suitable for the case.What I am trying to do is store a history of selected points, that is why I need such a signal to keep track of previous coordinates. I tried looking into implementing a custom Q3DInputHandler, but not sure that it can resolve the issue. I would be grateful for any advice on the solution.
-
Although this topic is quite old, you were on the right track. The
selectedPointChanged(const QPoint &position)
signal provides the position of the selected point in yourQtDataVisualization::QSurfaceDataProxy
, which can be used to access the desired information by usingQtDataVisualization::QSurfaceDataProxy::itemAt(const QPoint &position)
. Below a minimalistic outline of the basic steps:using namespace QtDataVisualization; ... # surface init (should already exist) Q3DSurface *surfacePlot = new Q3DSurface(); QSurfaceDataProxy *surfaceDataProxy = new QSurfaceDataProxy(); QSurface3DSeries *surfaceDataSeries = new QSurface3DSeries(surfaceDataProxy); surfacePlot->addSeries(surfaceDataSeries); # connect the selectedPointChanged signal to e.g. your desired foo function # (adjust this to fit the required signal/slot type for your function) QObject::connect(surfaceDataSeries, &QSurface3DSeries::selectedPointChanged, foo); # the foo funciton should look like void foo(const QPoint &position) { if ((position.x() < 0) or (position.y() < 0)) return; // nothing selected QVector3D pos = surfaceDataProxy->itemAt(position)->position(); // (x,y,z) data for selected point ... # e.g. store the pos in some list }