Qx v0.7
Qt Extensions Library
|
The StandardItemModel class is a more robust variant of QStandardItemModel, which is a generic model for storing custom data. More...
#include <qx/widgets/qx-standarditemmodel.h>
Public Member Functions | |
StandardItemModel (int rows, int columns, QObject *parent=nullptr) | |
StandardItemModel (QObject *parent=nullptr) | |
void | forEachItem (const std::function< void(QStandardItem *)> &func, QModelIndex parent=QModelIndex()) const |
bool | isAutoTristate () |
void | selectAll () |
void | selectNone () |
void | setAutoTristate (bool autoTristate) |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
StandardItemModel derives from QStandardItemModel and therefore shares all of its functionality, but this Qx variant provides additional functionality and mechanisms that are missing from its base class.
Qx::StandardItemModel::StandardItemModel | ( | int | rows, |
int | columns, | ||
QObject * | parent = nullptr ) |
Constructs a new item model that initially has rows rows and columns columns, and that has the given parent.
Qx::StandardItemModel::StandardItemModel | ( | QObject * | parent = nullptr | ) |
Constructs a new item model with the given parent.
void Qx::StandardItemModel::forEachItem | ( | const std::function< void(QStandardItem *)> & | func, |
QModelIndex | parent = QModelIndex() ) const |
Calls a user-defined routine on multiple items within the model.
func | The function to call on each item. It must take a single argument of type QStandardItem* and return void . |
parent | A model index pointing to the item for processing to start at. A null index causes processing to start at the root item of the model, thereby calling the routine on all items. |
bool Qx::StandardItemModel::isAutoTristate | ( | ) |
Returns true
if the item model is set to auto tristate mode; otherwise returns false
.
void Qx::StandardItemModel::selectAll | ( | ) |
Sets the check state of all checkable items that are managed by the model to Qt::Checked.
void Qx::StandardItemModel::selectNone | ( | ) |
Sets the check state of all checkable items that are managed by the model to Qt::Unchecked.
void Qx::StandardItemModel::setAutoTristate | ( | bool | autoTristate | ) |
Enables treatment of all checkable child items as tristate if autoTristate is true
This enables model-wide automatic management of the state of parent items in the model (checked if all children are checked, unchecked if all children are unchecked, or partially checked if only some children are checked).
false
, items handled by the model that have the flag Qt::ItemIsAutoTristate will still be treated as such.
|
overridevirtual |
Reimplements: QStandardItemModel::setData(const QModelIndex& index, const QVariant& value, int role).