Class WTableView

public class WTableView
extends WAbstractItemView
An MVC View widget for tabular data.

The view displays data from a WAbstractItemModel in a table. It provides incremental rendering, without excessive use of client- or serverside resources.

The rendering (and editing) of items is handled by a WAbstractItemDelegate, by default it uses WItemDelegate which renders data of all predefined roles (see also ItemDataRole), including text, icons, checkboxes, and tooltips.

The view provides virtual scrolling in both horizontal and vertical directions, and can therefore be used to display large data models (with large number of columns and rows).

When the view is updated, it will read the data from the model row per row, starting at the top visible row. If (r1,c1) and (r2,c2) are two model indexes of visible table cells, and r1 < r2 or r1 == r2 and c1 < c2, then the data for the first model index is read before the second. Keep this into account when implementing a custom WAbstractItemModel if you want to optimize performance.

The view may support editing of items, if the model indicates support (see the ItemFlag.ItemIsEditable flag). You can define triggers that initiate editing of an item using WAbstractItemView#setEditTriggers(). The actual editing is provided by the item delegate (you can set an appropriate delegate for one column using WAbstractItemView#setItemDelegateForColumn()). Using WAbstractItemView#setEditOptions() you can customize if and how the view deals with multiple editors.

By default, all columns are given a width of 150px. Column widths of all columns can be set through the API method setColumnWidth(), and also by the user using handles provided in the header.

If the model supports sorting (WAbstractItemModel#sort()), such as the WStandardItemModel, then you can enable sorting buttons in the header, using WAbstractItemView#setSortingEnabled().

You can allow selection on row or item level (using WAbstractItemView#setSelectionBehavior()), and selection of single or multiple items (using WAbstractItemView#setSelectionMode()), and listen for changes in the selection using the WAbstractItemView.selectionChanged() signal.

You may enable drag & drop support for this view, whith awareness of the items in the model. When enabling dragging (see WAbstractItemView#setDragEnabled()), the current selection may be dragged, but only when all items in the selection indicate support for dragging (controlled by the ItemFlag.ItemIsDragEnabled flag), and if the model indicates a mime-type (controlled by WAbstractItemModel.getMimeType()). Likewise, by enabling support for dropping (see WAbstractItemView#setDropsEnabled()), the view may receive a drop event on a particular item, at least if the item indicates support for drops (controlled by the ItemFlag.ItemIsDropEnabled flag).

You may also react to mouse click events on any item, by connecting to one of the WAbstractItemView.clicked() or WAbstractItemView.doubleClicked() signals.

If a WTableView is not constrained in height (either by a layout manager or by WWidget#setHeight()), then it will grow according to the size of the model.