Qx v0.7
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::StandardItemModel Class Reference

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
 

Detailed Description

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.

Note
One significant functional difference from the base class version to be aware of is that the Qt::ItemIsAutoTristate flag of any item managed by this model will always be respected, regardless of which view it is attached to. In base Qt the auto tristate flag only functions for items behind a QTreeWidget.

Constructor & Destructor Documentation

◆ StandardItemModel() [1/2]

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.

◆ StandardItemModel() [2/2]

Qx::StandardItemModel::StandardItemModel ( QObject * parent = nullptr)

Constructs a new item model with the given parent.

Member Function Documentation

◆ forEachItem()

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.

Parameters
funcThe function to call on each item. It must take a single argument of type QStandardItem* and return void.
parentA 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.

◆ isAutoTristate()

bool Qx::StandardItemModel::isAutoTristate ( )

Returns true if the item model is set to auto tristate mode; otherwise returns false.

See also
setAutoTristate().

◆ selectAll()

void Qx::StandardItemModel::selectAll ( )

Sets the check state of all checkable items that are managed by the model to Qt::Checked.

See also
setAutoTristate().

◆ selectNone()

void Qx::StandardItemModel::selectNone ( )

Sets the check state of all checkable items that are managed by the model to Qt::Unchecked.

See also
setAutoTristate().

◆ setAutoTristate()

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).

Note
Even if this option is false, items handled by the model that have the flag Qt::ItemIsAutoTristate will still be treated as such.

◆ setData()

bool Qx::StandardItemModel::setData ( const QModelIndex & index,
const QVariant & value,
int role = Qt::EditRole )
overridevirtual

Reimplements: QStandardItemModel::setData(const QModelIndex& index, const QVariant& value, int role).


The documentation for this class was generated from the following files: