Qt Data Visualization 与数据进行交互

与数据进行交互

End users can interact with the rendered graph by using either the mouse or touch to rotate, zoom, or select data. Graphs can be rotated freely by holding down the right mouse button and moving the mouse. Zooming is done by rolling the mouse wheel. Selecting, if enabled, is done by pressing the left mouse button. The scene can be reset to the default camera view by clicking the mouse wheel. In touch devices, rotation is done by tap-and-move, selection by tap-and-hold, and zoom by pinch.

Qt Data Visualization has default handlers for mouse actions and touch gestures. For the default mouse controls, see Q3DInputHandler , and for the default touch controls, see QTouch3DInputHandler . The default handlers must be disabled when using customized input handlers.

The 自定义输入范例 illustrates how to use a custom input handler to select items upon mouseover instead of mouse click. The information below the mouse cursor is displayed as a popup.

In addition to perspective projection, orthographic projection can be used to create 2D graphs by replacing the default input handler with one that does not allow rotating the graph and setting the camera to view the graph directly from the side or from the top.

数据选定模式

All visualization types support selecting a single data item - a bar, a scatter item, or a surface vertex - using mouse, touch, and programmatically via the series APIs. The selected item is highlighted in the rendered graph, and selecting causes emission of a series specific signal for this purpose, for example, QBar3DSeries::selectedBarChanged (), which the application can handle.

Bar and surface graphs support slice selection modes, where the selected row or column is drawn in a separate viewport as a pseudo-2D graph. This makes it easier to see the actual values of a single row or column.

Bar graph additionally supports simply highlighting the whole row and/or column of the selected bar without opening the slice view. Bar graph also supports selecting/slicing a whole row and/or column by clicking the axis label, based on selection mode.

When multiple series are added to a graph, selecting an item in one of them will clear the selection on other series.