DataFrameModel: DataFrameModel

Description Usage Arguments Details Value Note Author(s)

Description

The qdataFrameModel function creates a DataFrameModel, an implementation of QAbstractItemModel using a data.frame. This makes it easy and fast to display and edit a data.frame in a QTableView or any other derivative of QAbstractItemView. The qdataFrame and qdataFrame<- functions allow one to get and set the data.frame underlying the model after construction.

Usage

1
2
3
4
qdataFrameModel(df, parent=NULL, useRoles=FALSE,
editable=character(), ...)
qdataFrame(model) <- value
qdataFrame(model)

Arguments

df

The data.frame that provides the data of the model

...

Extra arguments passed to qdataFrame<-, which actually loads the data.frame into the model.

model

DataFrameModel instance

parent

The parent QObject

useRoles

Whether to interpret column names as indicating alternative roles; see details.

editable

Character vector of column names in the data.frame that should be editable

value

A data.frame that provides the data of the model

Details

qdataFrameModel: While a simple data.frame can be displayed as a textual table, fancier tables require multiple data columns mapped to a single model column, each playing a separate 'role'. To specify additional roles, pass useRoles = TRUE. A role may be any string; those used by Qt are listed in the Qt::ItemDataRole enumeration. The display and edit roles are reserved (see below). See the documentation of the QStyledItemDelegate class for its expected data types for each role.

A simple way to encode this is in the column name, syntax: [.headerName1][.headerName2][.etc].role. Examples:

The set of model columns is derived from the unique header names. Display-role columns are those not prefixed by a period. If the column name in the data matches a string in the editable argument, the data is used for both the edit and display roles.

Value

qdataFrameModel: An instance of C++ DataFrameModel

Note

Calling the headerData method on DataFrameModel from R will not yield the expected result, because Smoke does not know of DataFrameModel and thus misses the override of the non-pure virtual. We can special case this if need-be.

Author(s)

Michael Lawrence


ggobi/qtbase documentation built on May 17, 2019, 3:15 a.m.