QgsAttributeTableView class
Provides a table view of features of a QgsVectorLayer.
Contents
This can either be used as a standalone widget. QgsBrowser features a reference implementation. Or this can be used within the QgsDualView stacked widget.
Constructors, destructors, conversion operators
- QgsAttributeTableView(QWidget* parent = nullptr)
- Constructor for QgsAttributeTableView.
Public functions
- auto eventFilter(QObject* object, QEvent* event) -> bool override
- This event filter is installed on the verticalHeader to intercept mouse press and release events.
- auto selectedFeaturesIds() const -> QList<QgsFeatureId>
- Returns the selected features in the attribute table in table sorted order.
- void setAttributeTableConfig(const QgsAttributeTableConfig& config)
- Set the attribute table config which should be used to control the appearance of the attribute table.
- void setFeatureSelectionManager(QgsIFeatureSelectionManager* featureSelectionManager)
- setFeatureSelectionManager
Signals
- void columnResized(int column, int width)
- Emitted when a column in the view has been resized.
- void willShowContextMenu(QMenu* menu, const QModelIndex& atIndex)
- Is emitted, in order to provide a hook to add additional* menu entries to the context menu.
Protected functions
- void closeEvent(QCloseEvent* event) override
- Saves geometry to the settings on close.
- void contextMenuEvent(QContextMenuEvent* event) override
- Is called when the context menu will be shown.
- void keyPressEvent(QKeyEvent* event) override
- Called for key press events Disables selection change by only pressing an arrow key.
- void mouseMoveEvent(QMouseEvent* event) override
- Called for mouse move events on a table cell.
- void mousePressEvent(QMouseEvent* event) override
- Called for mouse press events on a table cell.
- void mouseReleaseEvent(QMouseEvent* event) override
- Called for mouse release events on a table cell.
Function documentation
bool QgsAttributeTableView:: eventFilter(QObject* object,
QEvent* event) override
This event filter is installed on the verticalHeader to intercept mouse press and release events.
| Parameters | |
|---|---|
| object | The object which is the target of the event. |
| event | The intercepted event |
| Returns | Returns always false, so the event gets processed |
These are used to disable / enable live synchronisation with the map canvas selection which can be slow due to recurring canvas repaints.
QList<QgsFeatureId> QgsAttributeTableView:: selectedFeaturesIds() const
Returns the selected features in the attribute table in table sorted order.
| Returns | The selected features in the attribute table in the order sorted by the table. |
|---|
void QgsAttributeTableView:: setAttributeTableConfig(const QgsAttributeTableConfig& config)
Set the attribute table config which should be used to control the appearance of the attribute table.
void QgsAttributeTableView:: setFeatureSelectionManager(QgsIFeatureSelectionManager* featureSelectionManager)
setFeatureSelectionManager
| Parameters | |
|---|---|
| featureSelectionManager | We will take ownership |
void QgsAttributeTableView:: columnResized(int column,
int width) signal
Emitted when a column in the view has been resized.
| Parameters | |
|---|---|
| column | column index (starts at 0) |
| width | new width in pixel |
void QgsAttributeTableView:: willShowContextMenu(QMenu* menu,
const QModelIndex& atIndex) signal
Is emitted, in order to provide a hook to add additional* menu entries to the context menu.
| Parameters | |
|---|---|
| menu | If additional QMenuItems are added, they will show up in the context menu. |
| atIndex | The QModelIndex, to which the context menu belongs. Relative to the source model. In most cases, this will be a QgsAttributeTableFilterModel |
void QgsAttributeTableView:: closeEvent(QCloseEvent* event) override protected
Saves geometry to the settings on close.
| Parameters | |
|---|---|
| event | not used |
void QgsAttributeTableView:: contextMenuEvent(QContextMenuEvent* event) override protected
Is called when the context menu will be shown.
| Parameters | |
|---|---|
| event | The associated event object. |
Emits a willShowContextMenu() signal, so the menu can be populated by other parts of the application.
void QgsAttributeTableView:: keyPressEvent(QKeyEvent* event) override protected
Called for key press events Disables selection change by only pressing an arrow key.
| Parameters | |
|---|---|
| event | The mouse event |
void QgsAttributeTableView:: mouseMoveEvent(QMouseEvent* event) override protected
Called for mouse move events on a table cell.
| Parameters | |
|---|---|
| event | The mouse event |
Disables selection change for these events.
void QgsAttributeTableView:: mousePressEvent(QMouseEvent* event) override protected
Called for mouse press events on a table cell.
| Parameters | |
|---|---|
| event | The mouse event |
Disables selection change for these events.
void QgsAttributeTableView:: mouseReleaseEvent(QMouseEvent* event) override protected
Called for mouse release events on a table cell.
| Parameters | |
|---|---|
| event | The mouse event |
Disables selection change for these events.