DataView

class qte.DataView(parent=None)

A customised subclass of PySide.QtGui.QTableView.

The following defaults are set:

The following new features have been added:

  • A new currentRowChanged signal is emitted from the view when the current row changes. In Qt, this has to be accessed through the selection model.
  • A column widget may be set to the widget of a piece of text. See setColumnWidth for more information.
  • setModel allows communication back to the model through the model’s setView and unSetView methods. See setModel for more information.
  • Application.saveState and Application.restoreState are supported through the saveState and restoreState methods. Currently, only the column widths are saved.
  • Once a cell has been edited, the current cell moves down a row, mimicking the behaviour of most spreadsheet programs.
  • The view has copy and paste support.

Members

Properties

DataView.copyRole

The PySide.QtCore.Qt.ItemRole to use when copying data form the table The default is DisplayRole

DataView.defaults

A dict containing default value to use when editing pending data.

Each value in this dict should be keyed by the column number. If no default is set, None is used.

DataView.pasteRole

The PySide.QtCore.Qt.ItemRole to use when pasting data into the table. The default is EditRole

New Methods

DataView.copy()

Copy the selection to the system clipboard.

Data is copied as text in a tab-separated format similar to that used by most spreadsheet programs.

DataView.nextCell()

Move to the next cell down if possible. If the current cell is in the last row, nothing happens.

DataView.paste(text=None)

Paste tabular data into the table, overwriting existing.

The data is written to each cell using model().setData with the role specified in pasteRole. Note that no data conversion is done and all the data is pasted as strings.

The exact operation of this depends on the selection: If a range of cells is selected, then pasteToSelection is used. If nothing is selected, pasteAll is used.

If text is not specified, the contents of the clipboard are used.

DataView.pasteAll(data)

Paste data to the current index, filling down and right.

data is an iterable of rows, each row being an iterable of columns. As much of the data is pasted as possible, filling down and right from the current index. Pasting stops either when rows and columns run out or when the data runs out. The data is pasted one row at a time and a check is made after each row to determine if there is space for more.

DataView.pasteToSelection(data)

Paste data to overwrite the selected indexes.

data is an iterable of rows, each row being an iterable of columns. The data is pasted to fill the selected range, repeating as necessary. The selection is assumed to be contiguous between the smallest and largest selected indexes.

DataView.restoreState(state)

Restore the object state to state.

DataView.saveState()

Return the state of the object to save using Application.saveState.

DataView.setColumnWidth(column, width)

Sets the width of the given column to the width specified.

width may be a string, in which case textWidth is used to calculate the width of the text on this widget.

DataView.setModels(*models)

Connect a list of proxy models to this view.

This is a convenience function for common cases when a DataModel with a series of proxy models are used. The models listed should be in hierarchal order, e.g.:

setModels(proxy1, proxy2, datamodel)

is equivalent to:

setModel(proxy1)
proxy1.setSourceModel(proxy2)
proxy2.setSourceModel(datamodel)

The last model should be an actual data model, not a proxy.

DataView.saveState()

Return the state of the object to save using Application.saveState.

DataView.saveState()

Return the state of the object to save using Application.saveState.

Re-implemented Methods

DataView.setColumnWidth(column, width)

Sets the width of the given column to the width specified.

width may be a string, in which case textWidth is used to calculate the width of the text on this widget.

DataView.setItemDelegate(delegate)
DataView.setItemDelegateForColumn(column, delegate)
DataView.setItemDelegateForRow(row, delegate)
DataView.setModel(model)

Set the model displayed in the view.

When a model is set, its setView method is called if it exists. Similarly, unsetView is called when the model is removed from the view. These methods allow the model to perform specific action on the view, e.g. connecting to some of its signals.

Signals

DataView.currentRowChanged(dict)

Project Versions

Table Of Contents

Previous topic

DataModel

Next topic

DateEdit

This Page