qtbase (version 1.1.0)

DataFrameModel: DataFrameModel

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

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

Value

  • qdataFrameModel: An instance of C++ DataFrameModel

code

editable

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:

  • .carColor.background(background color for carColor column)
.foreground (foreground color for all columns) .firstName.lastName.font (special font for first and last name columns)