2.8. QeVectorView - 1D Vector Display Widget

2.8.1. Overview

QeVectorView is a dual-view widget for displaying 1D vector data. It inherits from QMainWindow and contains a vertically split layout with an embedded QePlot widget (the graphical view) in the top pane and a QTableView (the tabular editor) in the bottom pane. The plot view shows the data as a 1D curve with index values on the X axis; the table view presents the data as an editable single-column table backed by a QeArrayModel.

The Plot and Table panes can be toggled independently through toolbar actions or programmatically via the visibility control methods.

../_images/qevectorview_01.png

QeVectorView widget

2.8.1.1. Constructor

The constructor signature is

QeVectorView(parent: QWidget = None, designMode: boolean = False)

Parameters:

  • parent (QWidget, optional) – Parent widget.

  • designMode (bool, default False) – Set to True when instantiated from Qt Designer.

Example:

# Any Qt Widget needs an Application running
from PySide6.QtWidgets import QApplication
app = QApplication([])
from cut.wdglib.widgets import QeVectorView
vv = QeVectorView()
vv.show()

2.8.1.2. Inheritance Hierarchy

QeVectorView inherits from QMainWindow, giving it native support for toolbars, dock widgets, and menu bars:

hide empty members
hide empty attributes

class QeVectorView
class QMainWindow <<PySide6.QtWidgets>>
class QWidget <<PySide6.QtWidgets>>
class QObject <<PySide6.QtCore>>
class QPaintDevice <<PySide6.QtGui>>
class ShibokenObject <<Shiboken>>
class object

QeVectorView --|> QMainWindow
QMainWindow --|> QWidget
QWidget --|> QObject
QObject --|> QPaintDevice
QPaintDevice --|> ShibokenObject
ShibokenObject --|> object

2.8.2. Visibility Control

cut.wdglib.widgets.isPlotShown() bool

Return whether the plot view pane is currently visible.

Returns:

True if the plot is shown. Default: True.

cut.wdglib.widgets.setPlotShown(show: bool) None

Show or hide the plot view pane. Emits PlotShownChanged.

Parameters:

showTrue to show the plot.

cut.wdglib.widgets.resetPlotShown() None

Reset the plot view to shown (True).

cut.wdglib.widgets.isTableShown() bool

Return whether the table view pane is currently visible.

Returns:

True if the table is shown. Default: False.

cut.wdglib.widgets.setTableShown(show: bool) None

Show or hide the table view pane. Emits TableShownChanged.

Parameters:

showTrue to show the table.

cut.wdglib.widgets.resetTableShown() None

Reset the table view to hidden (False).

Known issue: The current implementation calls setPlotShown(False) instead of setTableShown(False), which hides the plot rather than restoring table visibility to False. See the Notes section.

cut.wdglib.widgets.isPlotDisabled() bool

Return whether the plot view is disabled. The plot is automatically disabled when the data type cannot be displayed (e.g., string data).

Returns:

True if the plot is disabled. Default: False.

cut.wdglib.widgets.setPlotDisable(disabled: bool) None

Enable or disable the plot view. When disabled, the plot is hidden and the table is shown. Emits PlotDisabledChanged.

Parameters:

disabledTrue to disable the plot view.

cut.wdglib.widgets.resetPlotDisabled() None

Reset the plot to enabled (False for the disabled flag).

2.8.3. Data Loading

cut.wdglib.widgets.setNumpyNdArray(data: object) None

Set the vector data from a 1-D NumPy array. The data is loaded into both the plot view and the table view.

The widget makes an internal copy of the data. Table cell edits are synchronized back to the plot view in real time.

Supported dtypes include int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64, and bool.

Passing None, an empty array, a 2-D array, or an unsupported dtype will silently clear the plot without raising an error.

Parameters:

data – A 1-D NumPy array, or None to clear the plot.

Example:

import numpy as np
from cut.wdglib.widgets import QeVectorView

vv = QeVectorView()
data = np.arange(100, dtype=np.float64)
vv.setNumpyNdArray(data)
cut.wdglib.widgets.getNumpyNdArray() object

Return the current vector data as a 1-D NumPy ndarray. If the data has been modified through the table view, the returned array reflects those edits.

Returns:

NumPy ndarray with shape matching the original data passed to setNumpyNdArray(), or None if no data is loaded or if the data type is String, Boolean, or NotSet.

Example:

arr = vv.getNumpyNdArray()
print(f"Shape: {arr.shape}, dtype: {arr.dtype}")

2.8.4. Cell Coordinate Methods

cut.wdglib.widgets.showCell(pos: PySide6.QtCore.QPoint) None

Public slot that converts plot coordinates to table cell coordinates, scrolls to and selects the corresponding cell in the table view.

Parameters:

pos – Coordinates from the plot canvas.

2.8.5. Signals

cut.wdglib.widgets.PlotShownChanged(visible: bool)

Emitted when the plot view visibility changes via setPlotShown().

Parameters:

visibleTrue if the plot is now shown.

cut.wdglib.widgets.TableShownChanged(visible: bool)

Documented as emitted when the table view visibility changes via setTableShown().

Known issue: The current implementation emits PlotShownChanged instead of TableShownChanged when setTableShown() is called. Connecting to this signal will not receive notifications. Use PlotShownChanged as a workaround if you need to detect table visibility changes.

Parameters:

visibleTrue if the table is now shown.

cut.wdglib.widgets.PlotDisabledChanged(disabled: bool)

Emitted when the plot disabled state changes via setPlotDisable().

Parameters:

disabledTrue if the plot is now disabled.

cut.wdglib.widgets.commitData(widget: QWidget)

Emitted when a table cell edit is committed back to the internal data and the plot view is updated. The widget argument is the QeVectorView instance itself.

Parameters:

widget – The QeVectorView widget that committed the data.

The standard QMainWindow and QWidget signals are also available:

  • customContextMenuRequested(pos: QPoint)

  • destroyed(obj: object = None)

  • objectNameChanged(name: str)

  • windowTitleChanged(title: str)

  • windowIconChanged(icon: QIcon)

  • windowIconTextChanged(text: str)

  • iconSizeChanged(size: QSize)

  • toolButtonStyleChanged(style: Qt.ToolButtonStyle)

  • tabifiedDockWidgetActivated(widget: QDockWidget)

2.8.6. QeTypes Enum

The QeTypes enum is importable from cut.common.pyb:

QeTypes.Int8
QeTypes.Int16
QeTypes.Int32
QeTypes.Int64
QeTypes.UInt8
QeTypes.UInt16
QeTypes.UInt32
QeTypes.UInt64
QeTypes.Float
QeTypes.Double
QeTypes.String
QeTypes.Boolean
QeTypes.NotSet

2.8.7. Type Conversion

When data is passed through setNumpyNdArray(), the widget converts the NumPy array into a typed std::shared_ptr<std::vector<...>> and feeds it to the embedded QePlot’s internal setArrayData overload. The conversion rules are:

  • int8, int16, uint8, uint16, bool -> converted to float in QePlot

  • int32, int64, uint32, uint64 -> converted to double in QePlot

  • float32, float64 -> passed through directly

Each call to setNumpyNdArray() clears any previously plotted data and creates a single new curve in the embedded QePlot.

2.8.8. Example Usage

Basic vector display:

import numpy as np
from cut.wdglib.widgets import QeVectorView
from PySide6.QtWidgets import QApplication

app = QApplication([])
vv = QeVectorView()

data = np.arange(100, dtype=np.float64)
vv.setNumpyNdArray(data)

# Show both plot and table
vv.setTableShown(True)
vv.setPlotShown(True)

vv.show()
app.exec()

Data roundtrip with edits:

import numpy as np
from cut.wdglib.widgets import QeVectorView

vv = QeVectorView()
original = np.arange(50, dtype=np.float64)
vv.setNumpyNdArray(original)

# After editing cells in the table view:
data = vv.getNumpyNdArray()
print(f"Shape: {data.shape}, dtype: {data.dtype}")

Clearing and re-plotting:

import numpy as np
from cut.wdglib.widgets import QeVectorView

vv = QeVectorView()
vv.setNumpyNdArray(np.arange(50, dtype=np.float64))

# Clear by passing None
vv.setNumpyNdArray(None)

# Repopulate with different data
vv.setNumpyNdArray(np.arange(50, 0, -1, dtype=np.float64))

Various dtypes:

import numpy as np
from cut.wdglib.widgets import QeVectorView

vv = QeVectorView()

# uint16 data (converted to float internally)
samples = np.array([100, 150, 200, 180, 220, 250], dtype=np.uint16)
vv.setNumpyNdArray(samples)

# Verify roundtrip
recovered = vv.getNumpyNdArray()
print(f"dtype preserved: {recovered.dtype == np.uint16}")  # True

2.8.9. Notes

  • QeVectorView inherits from QMainWindow, not QWidget. This means it supports toolbars, dock widgets, and a menu bar natively.

  • The embedded QePlot widget’s toolbar is docked into the QeVectorView’s main window. The QePlot methods (zoom, line/scatter toggle, Y-axis scale, export) are available through the toolbar but are not directly callable from Python on the QeVectorView instance – they are not part of the exposed Python API surface.

  • Default visibility after construction: plot shown (True), table hidden (False), plot enabled (False for disabled flag).

  • When data of a non-numeric type is loaded, the plot view is automatically disabled (setPlotDisable(True)). The table view remains functional.

  • Table cell edits are synchronized back to the plot view in real time. The dataChanged signal from the QeArrayModel triggers HandleModelDataChanged which re-feeds the edited data to the embedded QePlot and emits commitData(this).

  • getNumpyNdArray() returns None for Boolean data, even though setNumpyNdArray() accepts Boolean arrays.

  • Known bug: setTableShown() emits PlotShownChanged instead of TableShownChanged. Code connecting to TableShownChanged will not receive notifications.

  • Known bug: resetTableShown() calls setPlotShown(False) instead of setTableShown(False), which hides the plot rather than restoring m_TableShown to False. After calling resetTableShown() the table remains shown (isTableShown() returns True), and the plot is hidden instead.

  • Known issue: The Pointer toolbar action (actionPointer, shortcut Ctrl+Space) is a stub. The connect/disconnect logic for linking plot mouse coordinates to table cell selection is commented out in the implementation.

  • Passing None, a 2D array, or an empty array to setNumpyNdArray() silently clears the widget (sets an empty int8_t vector) without raising an error.