Qt 4.8
Public Types | Public Functions | Protected Functions | Protected Variables | Friends | Related Functions | List of all members
QStandardItem Class Reference

The QStandardItem class provides an item for use with the QStandardItemModel class. More...

#include <qstandarditemmodel.h>

Public Types

enum  ItemType { Type = 0, UserType = 1000 }
 This enum describes the types that are used to describe standard items. More...
 

Public Functions

QString accessibleDescription () const
 Returns the item's accessible description. More...
 
QString accessibleText () const
 Returns the item's accessible text. More...
 
void appendColumn (const QList< QStandardItem *> &items)
 Appends a column containing items. More...
 
void appendRow (const QList< QStandardItem *> &items)
 Appends a row containing items. More...
 
void appendRow (QStandardItem *item)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Appends a row containing item. More...
 
void appendRows (const QList< QStandardItem *> &items)
 Appends rows containing items. More...
 
QBrush background () const
 Returns the brush used to render the item's background. More...
 
Qt::CheckState checkState () const
 Returns the checked state of the item. More...
 
QStandardItemchild (int row, int column=0) const
 Returns the child item at (row, column) if one has been set; otherwise returns 0. More...
 
virtual QStandardItemclone () const
 Returns a copy of this item. More...
 
int column () const
 Returns the column where the item is located in its parent's child table, or -1 if the item has no parent. More...
 
int columnCount () const
 Returns the number of child item columns that the item has. More...
 
virtual QVariant data (int role=Qt::UserRole+1) const
 Returns the item's data for the given role, or an invalid QVariant if there is no data for the role. More...
 
Qt::ItemFlags flags () const
 Returns the item flags for the item. More...
 
QFont font () const
 Returns the font used to render the item's text. More...
 
QBrush foreground () const
 Returns the brush used to render the item's foreground (e. More...
 
bool hasChildren () const
 Returns true if this item has any children; otherwise returns false. More...
 
QIcon icon () const
 Returns the item's icon. More...
 
QModelIndex index () const
 Returns the QModelIndex associated with this item. More...
 
void insertColumn (int column, const QList< QStandardItem *> &items)
 Inserts a column at column containing items. More...
 
void insertColumns (int column, int count)
 Inserts count columns of child items at column column. More...
 
void insertRow (int row, const QList< QStandardItem *> &items)
 Inserts a row at row containing items. More...
 
void insertRow (int row, QStandardItem *item)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts a row at row containing item. More...
 
void insertRows (int row, const QList< QStandardItem *> &items)
 Inserts items at row. More...
 
void insertRows (int row, int count)
 Inserts count rows of child items at row row. More...
 
bool isCheckable () const
 Returns whether the item is user-checkable. More...
 
bool isDragEnabled () const
 Returns whether the item is drag enabled. More...
 
bool isDropEnabled () const
 Returns whether the item is drop enabled. More...
 
bool isEditable () const
 Returns whether the item can be edited by the user. More...
 
bool isEnabled () const
 Returns whether the item is enabled. More...
 
bool isSelectable () const
 Returns whether the item is selectable by the user. More...
 
bool isTristate () const
 Returns whether the item is tristate; that is, if it's checkable with three separate states. More...
 
QStandardItemModelmodel () const
 Returns the QStandardItemModel that this item belongs to. More...
 
virtual bool operator< (const QStandardItem &other) const
 Returns true if this item is less than other; otherwise returns false. More...
 
QStandardItemparent () const
 Returns the item's parent item, or 0 if the item has no parent. More...
 
 QStandardItem ()
 Constructs an item. More...
 
 QStandardItem (const QString &text)
 Constructs an item with the given text. More...
 
 QStandardItem (const QIcon &icon, const QString &text)
 Constructs an item with the given icon and text. More...
 
 QStandardItem (int rows, int columns=1)
 Constructs an item with rows rows and columns columns of child items. More...
 
virtual void read (QDataStream &in)
 Reads the item from stream in. More...
 
void removeColumn (int column)
 Removes the given column. More...
 
void removeColumns (int column, int count)
 Removes count columns at column column. More...
 
void removeRow (int row)
 Removes the given row. More...
 
void removeRows (int row, int count)
 Removes count rows at row row. More...
 
int row () const
 Returns the row where the item is located in its parent's child table, or -1 if the item has no parent. More...
 
int rowCount () const
 Returns the number of child item rows that the item has. More...
 
void setAccessibleDescription (const QString &accessibleDescription)
 Sets the item's accessible description to the string specified by accessibleDescription. More...
 
void setAccessibleText (const QString &accessibleText)
 Sets the item's accessible text to the string specified by accessibleText. More...
 
void setBackground (const QBrush &brush)
 Sets the item's background brush to the specified brush. More...
 
void setCheckable (bool checkable)
 Sets whether the item is user-checkable. More...
 
void setCheckState (Qt::CheckState checkState)
 Sets the check state of the item to be state. More...
 
void setChild (int row, int column, QStandardItem *item)
 Sets the child item at (row, column) to item. More...
 
void setChild (int row, QStandardItem *item)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the child at row to item. More...
 
void setColumnCount (int columns)
 Sets the number of child item columns to columns. More...
 
virtual void setData (const QVariant &value, int role=Qt::UserRole+1)
 Sets the item's data for the given role to the specified value. More...
 
void setDragEnabled (bool dragEnabled)
 Sets whether the item is drag enabled. More...
 
void setDropEnabled (bool dropEnabled)
 Sets whether the item is drop enabled. More...
 
void setEditable (bool editable)
 Sets whether the item is editable. More...
 
void setEnabled (bool enabled)
 Sets whether the item is enabled. More...
 
void setFlags (Qt::ItemFlags flags)
 Sets the item flags for the item to flags. More...
 
void setFont (const QFont &font)
 Sets the font used to display the item's text to the given font. More...
 
void setForeground (const QBrush &brush)
 Sets the brush used to display the item's foreground (e. More...
 
void setIcon (const QIcon &icon)
 Sets the item's icon to the icon specified. More...
 
void setRowCount (int rows)
 Sets the number of child item rows to rows. More...
 
void setSelectable (bool selectable)
 Sets whether the item is selectable. More...
 
void setSizeHint (const QSize &sizeHint)
 Sets the size hint for the item to be size. More...
 
void setStatusTip (const QString &statusTip)
 Sets the item's status tip to the string specified by statusTip. More...
 
void setText (const QString &text)
 Sets the item's text to the text specified. More...
 
void setTextAlignment (Qt::Alignment textAlignment)
 Sets the text alignment for the item's text to the alignment specified. More...
 
void setToolTip (const QString &toolTip)
 Sets the item's tooltip to the string specified by toolTip. More...
 
void setTristate (bool tristate)
 Sets whether the item is tristate. More...
 
void setWhatsThis (const QString &whatsThis)
 Sets the item's "What's This?" help to the string specified by whatsThis. More...
 
QSize sizeHint () const
 Returns the size hint set for the item, or an invalid QSize if no size hint has been set. More...
 
void sortChildren (int column, Qt::SortOrder order=Qt::AscendingOrder)
 Sorts the children of the item using the given order, by the values in the given column. More...
 
QString statusTip () const
 Returns the item's status tip. More...
 
QStandardItemtakeChild (int row, int column=0)
 Removes the child item at (row, column) without deleting it, and returns a pointer to the item. More...
 
QList< QStandardItem * > takeColumn (int column)
 Removes column without deleting the column items, and returns a list of pointers to the removed items. More...
 
QList< QStandardItem * > takeRow (int row)
 Removes row without deleting the row items, and returns a list of pointers to the removed items. More...
 
QString text () const
 Returns the item's text. More...
 
Qt::Alignment textAlignment () const
 Returns the text alignment for the item's text. More...
 
QString toolTip () const
 Returns the item's tooltip. More...
 
virtual int type () const
 Returns the type of this item. More...
 
QString whatsThis () const
 Returns the item's "What's This?" help. More...
 
virtual void write (QDataStream &out) const
 Writes the item to stream out. More...
 
virtual ~QStandardItem ()
 Destructs the item. More...
 

Protected Functions

void emitDataChanged ()
 Causes the model associated with this item to emit a dataChanged() signal for this item. More...
 
QStandardItemoperator= (const QStandardItem &other)
 Assigns other's data and flags to this item. More...
 
 QStandardItem (const QStandardItem &other)
 Constructs a copy of other. More...
 
 QStandardItem (QStandardItemPrivate &dd)
 

Protected Variables

QScopedPointer< QStandardItemPrivated_ptr
 

Friends

class QStandardItemModel
 
class QStandardItemModelPrivate
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QStandardItem &item)
 Writes the QStandardItem item to stream out. More...
 
QDataStreamoperator>> (QDataStream &in, QStandardItem &item)
 Reads a QStandardItem from stream in into item. More...
 

Detailed Description

The QStandardItem class provides an item for use with the QStandardItemModel class.

Since
4.2

Items usually contain text, icons, or checkboxes.

Each item can have its own background brush which is set with the setBackground() function. The current background brush can be found with background(). The text label for each item can be rendered with its own font and brush. These are specified with the setFont() and setForeground() functions, and read with font() and foreground().

By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. Each item's flags can be changed by calling setFlags(). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked.

You can store application-specific data in an item by calling setData().

Each item can have a two-dimensional table of child items. This makes it possible to build hierarchies of items. The typical hierarchy is the tree, in which case the child table is a table with a single column (a list).

The dimensions of the child table can be set with setRowCount() and setColumnCount(). Items can be positioned in the child table with setChild(). Get a pointer to a child item with child(). New rows and columns of children can also be inserted with insertRow() and insertColumn(), or appended with appendRow() and appendColumn(). When using the append and insert functions, the dimensions of the child table will grow as needed.

An existing row of children can be removed with removeRow() or takeRow(); correspondingly, a column can be removed with removeColumn() or takeColumn().

An item's children can be sorted by calling sortChildren().

Subclassing

When subclassing QStandardItem to provide custom items, it is possible to define new types for them so that they can be distinguished from the base class. The type() function should be reimplemented to return a new type value equal to or greater than UserType .

Reimplement data() and setData() if you want to perform custom handling of data queries and/or control how an item's data is represented.

Reimplement clone() if you want QStandardItemModel to be able to create instances of your custom item class on demand (see QStandardItemModel::setItemPrototype()).

Reimplement read() and write() if you want to control how items are represented in their serialized form.

Reimplement operator<() if you want to control the semantics of item comparison. operator<() determines the sorted order when sorting items with sortChildren() or with QStandardItemModel::sort().

See also
QStandardItemModel, {Item View Convenience Classes}, {Model/View Programming}

Definition at line 66 of file qstandarditemmodel.h.

Enumerations

◆ ItemType

This enum describes the types that are used to describe standard items.

  • Type The default type for standard items.
  • UserType The minimum value for custom types. Values below UserType are reserved by Qt.

You can define new user types in QStandardItem subclasses to ensure that custom items are treated specially; for example, when items are sorted.

See also
type()
Enumerator
Type 
UserType 

Definition at line 230 of file qstandarditemmodel.h.

Constructors and Destructors

◆ QStandardItem() [1/6]

QStandardItem::QStandardItem ( )

Constructs an item.

Definition at line 701 of file qstandarditemmodel.cpp.

Referenced by clone().

703 {
705  d->q_ptr = this;
706 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.
QScopedPointer< QStandardItemPrivate > d_ptr

◆ QStandardItem() [2/6]

QStandardItem::QStandardItem ( const QString text)

Constructs an item with the given text.

Definition at line 711 of file qstandarditemmodel.cpp.

713 {
715  d->q_ptr = this;
716  setText(text);
717 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.
void setText(const QString &text)
Sets the item&#39;s text to the text specified.
QScopedPointer< QStandardItemPrivate > d_ptr

◆ QStandardItem() [3/6]

QStandardItem::QStandardItem ( const QIcon icon,
const QString text 
)

Constructs an item with the given icon and text.

Definition at line 722 of file qstandarditemmodel.cpp.

724 {
726  d->q_ptr = this;
727  setIcon(icon);
728  setText(text);
729 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setIcon(const QIcon &icon)
Sets the item&#39;s icon to the icon specified.
The QStandardItem class provides an item for use with the QStandardItemModel class.
void setText(const QString &text)
Sets the item&#39;s text to the text specified.
QScopedPointer< QStandardItemPrivate > d_ptr

◆ QStandardItem() [4/6]

QStandardItem::QStandardItem ( int  rows,
int  columns = 1 
)
explicit

Constructs an item with rows rows and columns columns of child items.

Definition at line 734 of file qstandarditemmodel.cpp.

736 {
738  d->q_ptr = this;
739  setRowCount(rows);
740  setColumnCount(columns);
741 }
double d
Definition: qnumeric_p.h:62
void setRowCount(int rows)
Sets the number of child item rows to rows.
#define Q_D(Class)
Definition: qglobal.h:2482
void setColumnCount(int columns)
Sets the number of child item columns to columns.
The QStandardItem class provides an item for use with the QStandardItemModel class.
QScopedPointer< QStandardItemPrivate > d_ptr

◆ ~QStandardItem()

QStandardItem::~QStandardItem ( )
virtual

Destructs the item.

This causes the item's children to be destructed as well.

Definition at line 784 of file qstandarditemmodel.cpp.

785 {
786 }

◆ QStandardItem() [5/6]

QStandardItem::QStandardItem ( const QStandardItem other)
protected

Constructs a copy of other.

Note that model() is not copied.

This function is useful when reimplementing clone().

Definition at line 759 of file qstandarditemmodel.cpp.

761 {
763  d->q_ptr = this;
764  operator=(other);
765 }
double d
Definition: qnumeric_p.h:62
QStandardItem & operator=(const QStandardItem &other)
Assigns other&#39;s data and flags to this item.
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.
QScopedPointer< QStandardItemPrivate > d_ptr

◆ QStandardItem() [6/6]

QStandardItem::QStandardItem ( QStandardItemPrivate dd)
protected
Warning
This function is not part of the public interface.

Definition at line 746 of file qstandarditemmodel.cpp.

747  : d_ptr(&dd)
748 {
750  d->q_ptr = this;
751 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.
QScopedPointer< QStandardItemPrivate > d_ptr

Functions

◆ accessibleDescription()

QString QStandardItem::accessibleDescription ( ) const
inline

Returns the item's accessible description.

The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

See also
setAccessibleDescription(), accessibleText()

Definition at line 144 of file qstandarditemmodel.h.

144  {
146  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ accessibleText()

QString QStandardItem::accessibleText ( ) const
inline

Returns the item's accessible text.

The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

See also
setAccessibleText(), accessibleDescription()

Definition at line 139 of file qstandarditemmodel.h.

139  {
141  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ appendColumn()

void QStandardItem::appendColumn ( const QList< QStandardItem *> &  items)
inline

Appends a column containing items.

If necessary, the row count is increased to the size of items.

See also
insertColumn()

Definition at line 307 of file qstandarditemmodel.h.

Referenced by QStandardItemModel::appendColumn().

308 { insertColumn(columnCount(), aitems); }
int columnCount() const
Returns the number of child item columns that the item has.
void insertColumn(int column, const QList< QStandardItem *> &items)
Inserts a column at column containing items.

◆ appendRow() [1/2]

void QStandardItem::appendRow ( const QList< QStandardItem *> &  items)
inline

Appends a row containing items.

If necessary, the column count is increased to the size of items.

See also
insertRow()

Definition at line 301 of file qstandarditemmodel.h.

Referenced by QStandardItemModel::appendRow().

302 { insertRow(rowCount(), aitems); }
void insertRow(int row, const QList< QStandardItem *> &items)
Inserts a row at row containing items.
int rowCount() const
Returns the number of child item rows that the item has.

◆ appendRow() [2/2]

void QStandardItem::appendRow ( QStandardItem item)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Appends a row containing item.

When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.

Definition at line 313 of file qstandarditemmodel.h.

314 { insertRow(rowCount(), aitem); }
void insertRow(int row, const QList< QStandardItem *> &items)
Inserts a row at row containing items.
int rowCount() const
Returns the number of child item rows that the item has.

◆ appendRows()

void QStandardItem::appendRows ( const QList< QStandardItem *> &  items)
inline

Appends rows containing items.

The column count will not change.

See also
insertRow()

Definition at line 304 of file qstandarditemmodel.h.

305 { insertRows(rowCount(), aitems); }
int rowCount() const
Returns the number of child item rows that the item has.
void insertRows(int row, const QList< QStandardItem *> &items)
Inserts items at row.

◆ background()

QBrush QStandardItem::background ( ) const
inline

Returns the brush used to render the item's background.

See also
foreground() setBackground()

Definition at line 124 of file qstandarditemmodel.h.

124  {
126  }
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ checkState()

Qt::CheckState QStandardItem::checkState ( ) const
inline

Returns the checked state of the item.

See also
setCheckState(), isCheckable()

Definition at line 134 of file qstandarditemmodel.h.

134  {
135  return Qt::CheckState(qvariant_cast<int>(data(Qt::CheckStateRole)));
136  }
CheckState
Definition: qnamespace.h:1607
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...

◆ child()

QStandardItem * QStandardItem::child ( int  row,
int  column = 0 
) const

Returns the child item at (row, column) if one has been set; otherwise returns 0.

See also
setChild(), takeChild(), parent()

Definition at line 1811 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModelPrivate::itemFromIndex(), QStandardItemModel::itemFromIndex(), and QStandardItemPrivate::sortChildren().

1812 {
1813  Q_D(const QStandardItem);
1814  int index = d->childIndex(row, column);
1815  if (index == -1)
1816  return 0;
1817  return d->children.at(index);
1818 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
QModelIndex index() const
Returns the QModelIndex associated with this item.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ clone()

QStandardItem * QStandardItem::clone ( ) const
virtual

Returns a copy of this item.

The item's children are not copied.

When subclassing QStandardItem, you can reimplement this function to provide QStandardItemModel with a factory that it can use to create new items on demand.

See also
QStandardItemModel::setItemPrototype(), operator=()

Definition at line 1982 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModelPrivate::createItem().

1983 {
1984  return new QStandardItem(*this);
1985 }
QStandardItem()
Constructs an item.

◆ column()

int QStandardItem::column ( ) const

Returns the column where the item is located in its parent's child table, or -1 if the item has no parent.

See also
row(), parent()

Definition at line 1457 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::mimeData(), and takeRow().

1458 {
1459  Q_D(const QStandardItem);
1460  QPair<int, int> pos = d->position();
1461  return pos.second;
1462 }
double d
Definition: qnumeric_p.h:62
T2 second
Definition: qpair.h:66
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ columnCount()

int QStandardItem::columnCount ( ) const

Returns the number of child item columns that the item has.

See also
setColumnCount(), rowCount()

Definition at line 1546 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::columnCount(), hasChildren(), QStandardItemModel::index(), insertColumns(), insertRow(), QStandardItemModel::mimeData(), removeColumns(), QStandardItemModel::removeColumns(), setColumnCount(), and takeColumn().

1547 {
1548  Q_D(const QStandardItem);
1549  return d->columnCount();
1550 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ data()

QVariant QStandardItem::data ( int  role = Qt::UserRole + 1) const
virtual

Returns the item's data for the given role, or an invalid QVariant if there is no data for the role.

Note
The default implementation treats Qt::EditRole and Qt::DisplayRole as referring to the same data.

Definition at line 845 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::data(), flags(), QStandardItemModel::headerData(), operator<(), and setCheckable().

846 {
847  Q_D(const QStandardItem);
848  role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
850  for (it = d->values.begin(); it != d->values.end(); ++it) {
851  if ((*it).role == role)
852  return (*it).value;
853  }
854  return QVariant();
855 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ emitDataChanged()

void QStandardItem::emitDataChanged ( )
protected

Causes the model associated with this item to emit a dataChanged() signal for this item.

Since
4.4

You normally only need to call this function if you have subclassed QStandardItem and reimplemented data() and/or setData().

See also
setData()

Definition at line 872 of file qstandarditemmodel.cpp.

873 {
875  if (d->model)
876  d->model->d_func()->itemChanged(this);
877 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ flags()

Qt::ItemFlags QStandardItem::flags ( ) const

Returns the item flags for the item.

The item flags determine how the user can interact with the item.

By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target.

See also
setFlags()

Definition at line 902 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::flags(), read(), and write().

903 {
904  QVariant v = data(Qt::UserRole - 1);
905  if (!v.isValid())
908  return Qt::ItemFlags(v.toInt());
909 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485

◆ font()

QFont QStandardItem::font ( ) const
inline

Returns the font used to render the item's text.

See also
setFont()

Definition at line 114 of file qstandarditemmodel.h.

114  {
116  }
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ foreground()

QBrush QStandardItem::foreground ( ) const
inline

Returns the brush used to render the item's foreground (e.

g. text).

\sa setForeground() background()

Definition at line 129 of file qstandarditemmodel.h.

129  {
131  }
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ hasChildren()

bool QStandardItem::hasChildren ( ) const

Returns true if this item has any children; otherwise returns false.

See also
rowCount(), columnCount(), child()

Definition at line 1780 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::hasChildren().

1781 {
1782  return (rowCount() > 0) && (columnCount() > 0);
1783 }
int columnCount() const
Returns the number of child item columns that the item has.
int rowCount() const
Returns the number of child item rows that the item has.

◆ icon()

QIcon QStandardItem::icon ( ) const
inline

Returns the item's icon.

See also
setIcon(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 83 of file qstandarditemmodel.h.

83  {
85  }
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ index()

QModelIndex QStandardItem::index ( ) const

Returns the QModelIndex associated with this item.

When you need to invoke item functionality in a QModelIndex-based API (e.g. QAbstractItemView), you can call this function to obtain an index that corresponds to the item's location in the model.

If the item is not associated with a model, an invalid QModelIndex is returned.

See also
model(), QStandardItemModel::itemFromIndex()

Definition at line 1476 of file qstandarditemmodel.cpp.

Referenced by child(), QStandardItemModel::dropMimeData(), takeChild(), takeColumn(), and takeRow().

1477 {
1478  Q_D(const QStandardItem);
1479  return d->model ? d->model->indexFromItem(this) : QModelIndex();
1480 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QModelIndex class is used to locate data in a data model.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ insertColumn()

void QStandardItem::insertColumn ( int  column,
const QList< QStandardItem *> &  items 
)

Inserts a column at column containing items.

If necessary, the row count is increased to the size of items.

See also
insertColumns(), insertRow()

Definition at line 1587 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::insertColumn().

1588 {
1589  Q_D(QStandardItem);
1590  if (column < 0)
1591  return;
1592  if (rowCount() < items.count())
1593  setRowCount(items.count());
1594  d->insertColumns(column, 1, items);
1595 }
double d
Definition: qnumeric_p.h:62
void setRowCount(int rows)
Sets the number of child item rows to rows.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
int rowCount() const
Returns the number of child item rows that the item has.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ insertColumns()

void QStandardItem::insertColumns ( int  column,
int  count 
)

Inserts count columns of child items at column column.

See also
insertColumn(), insertRows()

Definition at line 1617 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::insertColumns(), and setColumnCount().

1618 {
1619  Q_D(QStandardItem);
1620  if (columnCount() < column) {
1621  count += column - columnCount();
1622  column = columnCount();
1623  }
1624  d->insertColumns(column, count, QList<QStandardItem*>());
1625 }
double d
Definition: qnumeric_p.h:62
int columnCount() const
Returns the number of child item columns that the item has.
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
The QStandardItem class provides an item for use with the QStandardItemModel class.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ insertRow() [1/2]

void QStandardItem::insertRow ( int  row,
const QList< QStandardItem *> &  items 
)

Inserts a row at row containing items.

If necessary, the column count is increased to the size of items.

See also
insertRows(), insertColumn()

Definition at line 1558 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::insertRow().

1559 {
1560  Q_D(QStandardItem);
1561  if (row < 0)
1562  return;
1563  if (columnCount() < items.count())
1564  setColumnCount(items.count());
1565  d->insertRows(row, 1, items);
1566 }
double d
Definition: qnumeric_p.h:62
int columnCount() const
Returns the number of child item columns that the item has.
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
void setColumnCount(int columns)
Sets the number of child item columns to columns.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ insertRow() [2/2]

void QStandardItem::insertRow ( int  row,
QStandardItem item 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts a row at row containing item.

When building a list or a tree that has only one column, this function provides a convenient way to insert a single new item.

Definition at line 310 of file qstandarditemmodel.h.

311 { insertRow(arow, QList<QStandardItem*>() << aitem); }
void insertRow(int row, const QList< QStandardItem *> &items)
Inserts a row at row containing items.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ insertRows() [1/2]

void QStandardItem::insertRows ( int  row,
const QList< QStandardItem *> &  items 
)

Inserts items at row.

The column count wont be changed.

See also
insertRow(), insertColumn()

Definition at line 1573 of file qstandarditemmodel.cpp.

Referenced by QComboBox::insertItems(), QStandardItemModel::insertRows(), and setRowCount().

1574 {
1575  Q_D(QStandardItem);
1576  if (row < 0)
1577  return;
1578  d->insertRows(row, items);
1579 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ insertRows() [2/2]

void QStandardItem::insertRows ( int  row,
int  count 
)

Inserts count rows of child items at row row.

See also
insertRow(), insertColumns()

Definition at line 1602 of file qstandarditemmodel.cpp.

1603 {
1604  Q_D(QStandardItem);
1605  if (rowCount() < row) {
1606  count += row - rowCount();
1607  row = rowCount();
1608  }
1609  d->insertRows(row, count, QList<QStandardItem*>());
1610 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
int rowCount() const
Returns the number of child item rows that the item has.
The QStandardItem class provides an item for use with the QStandardItemModel class.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ isCheckable()

bool QStandardItem::isCheckable ( ) const
inline

Returns whether the item is user-checkable.

The default value is false.

See also
setCheckable(), checkState(), isTristate()

Definition at line 167 of file qstandarditemmodel.h.

Referenced by setCheckable().

167  {
168  return (flags() & Qt::ItemIsUserCheckable) != 0;
169  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ isDragEnabled()

bool QStandardItem::isDragEnabled ( ) const
inline

Returns whether the item is drag enabled.

An item that is drag enabled can be dragged by the user.

The default value is true.

Note that item dragging must be enabled in the view for dragging to work; see QAbstractItemView::dragEnabled.

See also
setDragEnabled(), isDropEnabled(), flags()

Definition at line 178 of file qstandarditemmodel.h.

178  {
179  return (flags() & Qt::ItemIsDragEnabled) != 0;
180  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ isDropEnabled()

bool QStandardItem::isDropEnabled ( ) const
inline

Returns whether the item is drop enabled.

When an item is drop enabled, it can be used as a drop target.

The default value is true.

See also
setDropEnabled(), isDragEnabled(), flags()

Definition at line 183 of file qstandarditemmodel.h.

183  {
184  return (flags() & Qt::ItemIsDropEnabled) != 0;
185  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ isEditable()

bool QStandardItem::isEditable ( ) const
inline

Returns whether the item can be edited by the user.

When an item is editable (and enabled), the user can edit the item by invoking one of the view's edit triggers; see QAbstractItemView::editTriggers.

The default value is true.

See also
setEditable(), flags()

Definition at line 157 of file qstandarditemmodel.h.

157  {
158  return (flags() & Qt::ItemIsEditable) != 0;
159  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ isEnabled()

bool QStandardItem::isEnabled ( ) const
inline

Returns whether the item is enabled.

When an item is enabled, the user can interact with it. The possible types of interaction are specified by the other item flags, such as isEditable() and isSelectable().

The default value is true.

See also
setEnabled(), flags()

Definition at line 152 of file qstandarditemmodel.h.

152  {
153  return (flags() & Qt::ItemIsEnabled) != 0;
154  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ isSelectable()

bool QStandardItem::isSelectable ( ) const
inline

Returns whether the item is selectable by the user.

The default value is true.

See also
setSelectable(), flags()

Definition at line 162 of file qstandarditemmodel.h.

162  {
163  return (flags() & Qt::ItemIsSelectable) != 0;
164  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ isTristate()

bool QStandardItem::isTristate ( ) const
inline

Returns whether the item is tristate; that is, if it's checkable with three separate states.

The default value is false.

See also
setTristate(), isCheckable(), checkState()

Definition at line 172 of file qstandarditemmodel.h.

172  {
173  return (flags() & Qt::ItemIsTristate) != 0;
174  }
Qt::ItemFlags flags() const
Returns the item flags for the item.

◆ model()

QStandardItemModel * QStandardItem::model ( ) const

Returns the QStandardItemModel that this item belongs to.

If the item is not a child of another item that belongs to the model, this function returns 0.

See also
index()

Definition at line 1490 of file qstandarditemmodel.cpp.

Referenced by QStandardItemPrivate::insertRows(), operator<(), QStandardItemModel::setHorizontalHeaderItem(), QStandardItemPrivate::setModel(), and QStandardItemModel::setVerticalHeaderItem().

1491 {
1492  Q_D(const QStandardItem);
1493  return d->model;
1494 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ operator<()

bool QStandardItem::operator< ( const QStandardItem other) const
virtual

Returns true if this item is less than other; otherwise returns false.

The default implementation uses the data for the item's sort role (see QStandardItemModel::sortRole) to perform the comparison if the item belongs to a model; otherwise, the data for the item's Qt::DisplayRole (text()) is used to perform the comparison.

sortChildren() and QStandardItemModel::sort() use this function when sorting items. If you want custom sorting, you can subclass QStandardItem and reimplement this function.

Definition at line 1918 of file qstandarditemmodel.cpp.

1919 {
1920  const int role = model() ? model()->sortRole() : Qt::DisplayRole;
1921  const QVariant l = data(role), r = other.data(role);
1922  // this code is copied from QSortFilterProxyModel::lessThan()
1923  switch (l.userType()) {
1924  case QVariant::Invalid:
1925  return (r.type() == QVariant::Invalid);
1926  case QVariant::Int:
1927  return l.toInt() < r.toInt();
1928  case QVariant::UInt:
1929  return l.toUInt() < r.toUInt();
1930  case QVariant::LongLong:
1931  return l.toLongLong() < r.toLongLong();
1932  case QVariant::ULongLong:
1933  return l.toULongLong() < r.toULongLong();
1934  case QMetaType::Float:
1935  return l.toFloat() < r.toFloat();
1936  case QVariant::Double:
1937  return l.toDouble() < r.toDouble();
1938  case QVariant::Char:
1939  return l.toChar() < r.toChar();
1940  case QVariant::Date:
1941  return l.toDate() < r.toDate();
1942  case QVariant::Time:
1943  return l.toTime() < r.toTime();
1944  case QVariant::DateTime:
1945  return l.toDateTime() < r.toDateTime();
1946  case QVariant::String:
1947  default:
1948  return l.toString().compare(r.toString()) < 0;
1949  }
1950 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
Definition: qvariant.cpp:2659
int sortRole
the item role that is used to query the model&#39;s data when sorting items
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Definition: qvariant.cpp:2675
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
int compare(const QString &s) const
Definition: qstring.cpp:5037
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
float toFloat(bool *ok=0) const
Returns the variant as a float if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2725
QFactoryLoader * l
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QStandardItemModel * model() const
Returns the QStandardItemModel that this item belongs to.
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330
QChar toChar() const
Returns the variant as a QChar if the variant has type() Char , Int , or UInt ; otherwise returns an ...
Definition: qvariant.cpp:2579

◆ operator=()

QStandardItem & QStandardItem::operator= ( const QStandardItem other)
protected

Assigns other's data and flags to this item.

Note that type() and model() are not copied.

This function is useful when reimplementing clone().

Definition at line 773 of file qstandarditemmodel.cpp.

Referenced by QStandardItem().

774 {
776  d->values = other.d_func()->values;
777  return *this;
778 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ parent()

QStandardItem * QStandardItem::parent ( ) const

Returns the item's parent item, or 0 if the item has no parent.

See also
child()

Definition at line 793 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::indexFromItem(), QStandardItemPrivate::insertColumns(), QStandardItemPrivate::insertRows(), QStandardItemModelPrivate::itemChanged(), and QStandardItemPrivate::setChild().

794 {
795  Q_D(const QStandardItem);
796  if (!d->model || (d->model->d_func()->root.data() != d->parent))
797  return d->parent;
798  return 0;
799 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ read()

void QStandardItem::read ( QDataStream in)
virtual

Reads the item from stream in.

Only the data and flags of the item are read, not the child items.

See also
write()

Definition at line 2008 of file qstandarditemmodel.cpp.

Referenced by operator>>().

2009 {
2010  Q_D(QStandardItem);
2011  in >> d->values;
2012  qint32 flags;
2013  in >> flags;
2014  setFlags(Qt::ItemFlags(flags));
2015 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
#define Q_D(Class)
Definition: qglobal.h:2482
void setFlags(Qt::ItemFlags flags)
Sets the item flags for the item to flags.
Qt::ItemFlags flags() const
Returns the item flags for the item.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ removeColumn()

void QStandardItem::removeColumn ( int  column)

Removes the given column.

The items that were in the column are deleted.

See also
takeColumn(), removeColumns(), removeRow()

Definition at line 1715 of file qstandarditemmodel.cpp.

1716 {
1717  removeColumns(column, 1);
1718 }
void removeColumns(int column, int count)
Removes count columns at column column.
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...

◆ removeColumns()

void QStandardItem::removeColumns ( int  column,
int  count 
)

Removes count columns at column column.

The items that were in those columns are deleted.

See also
removeColumn(), removeRows()

Definition at line 1753 of file qstandarditemmodel.cpp.

Referenced by removeColumn(), QStandardItemModel::removeColumns(), and setColumnCount().

1754 {
1755  Q_D(QStandardItem);
1756  if ((count < 1) || (column < 0) || ((column + count) > columnCount()))
1757  return;
1758  if (d->model)
1759  d->model->d_func()->columnsAboutToBeRemoved(this, column, column + count - 1);
1760  for (int row = d->rowCount() - 1; row >= 0; --row) {
1761  int i = d->childIndex(row, column);
1762  for (int j=i; j<i+count; ++j) {
1763  QStandardItem *oldItem = d->children.at(j);
1764  if (oldItem)
1765  oldItem->d_func()->setModel(0);
1766  delete oldItem;
1767  }
1768  d->children.remove(i, count);
1769  }
1770  d->columns -= count;
1771  if (d->model)
1772  d->model->d_func()->columnsRemoved(this, column, count);
1773 }
double d
Definition: qnumeric_p.h:62
int columnCount() const
Returns the number of child item columns that the item has.
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ removeRow()

void QStandardItem::removeRow ( int  row)

Removes the given row.

The items that were in the row are deleted.

See also
takeRow(), removeRows(), removeColumn()

Definition at line 1704 of file qstandarditemmodel.cpp.

1705 {
1706  removeRows(row, 1);
1707 }
void removeRows(int row, int count)
Removes count rows at row row.
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...

◆ removeRows()

void QStandardItem::removeRows ( int  row,
int  count 
)

Removes count rows at row row.

The items that were in those rows are deleted.

See also
removeRow(), removeColumn()

Definition at line 1726 of file qstandarditemmodel.cpp.

Referenced by removeRow(), QStandardItemModel::removeRows(), and setRowCount().

1727 {
1728  Q_D(QStandardItem);
1729  if ((count < 1) || (row < 0) || ((row + count) > rowCount()))
1730  return;
1731  if (d->model)
1732  d->model->d_func()->rowsAboutToBeRemoved(this, row, row + count - 1);
1733  int i = d->childIndex(row, 0);
1734  int n = count * d->columnCount();
1735  for (int j = i; j < n+i; ++j) {
1736  QStandardItem *oldItem = d->children.at(j);
1737  if (oldItem)
1738  oldItem->d_func()->setModel(0);
1739  delete oldItem;
1740  }
1741  d->children.remove(qMax(i, 0), n);
1742  d->rows -= count;
1743  if (d->model)
1744  d->model->d_func()->rowsRemoved(this, row, count);
1745 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int rowCount() const
Returns the number of child item rows that the item has.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ row()

int QStandardItem::row ( ) const

Returns the row where the item is located in its parent's child table, or -1 if the item has no parent.

See also
column(), parent()

Definition at line 1444 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::mimeData(), removeColumns(), and takeColumn().

1445 {
1446  Q_D(const QStandardItem);
1447  QPair<int, int> pos = d->position();
1448  return pos.first;
1449 }
double d
Definition: qnumeric_p.h:62
T1 first
Definition: qpair.h:65
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ rowCount()

int QStandardItem::rowCount ( ) const

Returns the number of child item rows that the item has.

See also
setRowCount(), columnCount()

Definition at line 1518 of file qstandarditemmodel.cpp.

Referenced by hasChildren(), QStandardItemModel::index(), insertColumn(), insertRows(), removeRows(), QStandardItemModel::removeRows(), QStandardItemModel::rowCount(), setRowCount(), sortChildren(), and takeRow().

1519 {
1520  Q_D(const QStandardItem);
1521  return d->rowCount();
1522 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setAccessibleDescription()

void QStandardItem::setAccessibleDescription ( const QString accessibleDescription)
inline

Sets the item's accessible description to the string specified by accessibleDescription.

The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

See also
accessibleDescription(), setAccessibleText()

Definition at line 295 of file qstandarditemmodel.h.

296 { setData(aaccessibleDescription, Qt::AccessibleDescriptionRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setAccessibleText()

void QStandardItem::setAccessibleText ( const QString accessibleText)
inline

Sets the item's accessible text to the string specified by accessibleText.

The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

See also
accessibleText(), setAccessibleDescription()

Definition at line 292 of file qstandarditemmodel.h.

293 { setData(aaccessibleText, Qt::AccessibleTextRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setBackground()

void QStandardItem::setBackground ( const QBrush brush)
inline

Sets the item's background brush to the specified brush.

See also
background() setForeground()

Definition at line 283 of file qstandarditemmodel.h.

284 { setData(abrush, Qt::BackgroundRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setCheckable()

void QStandardItem::setCheckable ( bool  checkable)

Sets whether the item is user-checkable.

If checkable is true, the item can be checked by the user; otherwise, the user cannot check the item.

The item delegate will render a checkable item with a check box next to the item's text.

See also
isCheckable(), setCheckState(), setTristate()

Definition at line 1320 of file qstandarditemmodel.cpp.

1321 {
1322  Q_D(QStandardItem);
1323  if (checkable && !isCheckable()) {
1324  // make sure there's data for the checkstate role
1325  if (!data(Qt::CheckStateRole).isValid())
1327  }
1328  d->changeFlags(checkable, Qt::ItemIsUserCheckable);
1329 }
double d
Definition: qnumeric_p.h:62
bool isCheckable() const
Returns whether the item is user-checkable.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
The QStandardItem class provides an item for use with the QStandardItemModel class.
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setCheckState()

void QStandardItem::setCheckState ( Qt::CheckState  state)
inline

Sets the check state of the item to be state.

See also
checkState(), setCheckable()

Definition at line 289 of file qstandarditemmodel.h.

290 { setData(acheckState, Qt::CheckStateRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setChild() [1/2]

void QStandardItem::setChild ( int  row,
int  column,
QStandardItem item 
)

Sets the child item at (row, column) to item.

This item (the parent item) takes ownership of item. If necessary, the row count and column count are increased to fit the item.

See also
child()

Definition at line 1792 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModel::dropMimeData(), and QStandardItemModel::itemFromIndex().

1793 {
1794  Q_D(QStandardItem);
1795  d->setChild(row, column, item, true);
1796 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setChild() [2/2]

void QStandardItem::setChild ( int  row,
QStandardItem item 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the child at row to item.

Definition at line 298 of file qstandarditemmodel.h.

299 { setChild(arow, 0, aitem); }
void setChild(int row, int column, QStandardItem *item)
Sets the child item at (row, column) to item.

◆ setColumnCount()

void QStandardItem::setColumnCount ( int  columns)

Sets the number of child item columns to columns.

If this is less than columnCount(), the data in the unwanted columns is discarded.

See also
columnCount(), setRowCount()

Definition at line 1530 of file qstandarditemmodel.cpp.

Referenced by insertRow(), and QStandardItem().

1531 {
1532  int cc = columnCount();
1533  if (cc == columns)
1534  return;
1535  if (cc < columns)
1536  insertColumns(qMax(cc, 0), columns - cc);
1537  else
1538  removeColumns(qMax(columns, 0), cc - columns);
1539 }
void removeColumns(int column, int count)
Removes count columns at column column.
int columnCount() const
Returns the number of child item columns that the item has.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void insertColumns(int column, int count)
Inserts count columns of child items at column column.

◆ setData()

void QStandardItem::setData ( const QVariant value,
int  role = Qt::UserRole + 1 
)
virtual

Sets the item's data for the given role to the specified value.

If you subclass QStandardItem and reimplement this function, your reimplementation should call emitDataChanged() if you do not call the base implementation of setData(). This will ensure that e.g. views using the model are notified of the changes.

Note
The default implementation treats Qt::EditRole and Qt::DisplayRole as referring to the same data.
See also
Qt::ItemDataRole, data(), setFlags()

Definition at line 814 of file qstandarditemmodel.cpp.

Referenced by QComboBox::insertItem(), setCheckable(), QStandardItemModel::setData(), setFlags(), and QStandardItemModel::setHeaderData().

815 {
817  role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
819  for (it = d->values.begin(); it != d->values.end(); ++it) {
820  if ((*it).role == role) {
821  if (value.isValid()) {
822  if ((*it).value.type() == value.type() && (*it).value == value)
823  return;
824  (*it).value = value;
825  } else {
826  d->values.erase(it);
827  }
828  if (d->model)
829  d->model->d_func()->itemChanged(this);
830  return;
831  }
832  }
833  d->values.append(QWidgetItemData(role, value));
834  if (d->model)
835  d->model->d_func()->itemChanged(this);
836 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
#define Q_D(Class)
Definition: qglobal.h:2482
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
The QStandardItem class provides an item for use with the QStandardItemModel class.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485

◆ setDragEnabled()

void QStandardItem::setDragEnabled ( bool  dragEnabled)

Sets whether the item is drag enabled.

If dragEnabled is true, the item can be dragged by the user; otherwise, the user cannot drag the item.

Note that you also need to ensure that item dragging is enabled in the view; see QAbstractItemView::dragEnabled.

See also
isDragEnabled(), setDropEnabled(), setFlags()

Definition at line 1383 of file qstandarditemmodel.cpp.

1384 {
1385  Q_D(QStandardItem);
1386  d->changeFlags(dragEnabled, Qt::ItemIsDragEnabled);
1387 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setDropEnabled()

void QStandardItem::setDropEnabled ( bool  dropEnabled)

Sets whether the item is drop enabled.

If dropEnabled is true, the item can be used as a drop target; otherwise, it cannot.

Note that you also need to ensure that drops are enabled in the view; see QWidget::acceptDrops(); and that the model supports the desired drop actions; see QAbstractItemModel::supportedDropActions().

See also
isDropEnabled(), setDragEnabled(), setFlags()

Definition at line 1416 of file qstandarditemmodel.cpp.

1417 {
1418  Q_D(QStandardItem);
1419  d->changeFlags(dropEnabled, Qt::ItemIsDropEnabled);
1420 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setEditable()

void QStandardItem::setEditable ( bool  editable)

Sets whether the item is editable.

If editable is true, the item can be edited by the user; otherwise, the user cannot edit the item.

How the user can edit items in a view is determined by the view's edit triggers; see QAbstractItemView::editTriggers.

See also
isEditable(), setFlags()

Definition at line 1258 of file qstandarditemmodel.cpp.

1259 {
1260  Q_D(QStandardItem);
1261  d->changeFlags(editable, Qt::ItemIsEditable);
1262 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setEnabled()

void QStandardItem::setEnabled ( bool  enabled)

Sets whether the item is enabled.

If enabled is true, the item is enabled, meaning that the user can interact with the item; if enabled is false, the user cannot interact with the item.

This flag takes precedence over the other item flags; e.g. if an item is not enabled, it cannot be selected by the user, even if the Qt::ItemIsSelectable flag has been set.

See also
isEnabled(), Qt::ItemIsEnabled, setFlags()

Definition at line 1226 of file qstandarditemmodel.cpp.

1227 {
1228  Q_D(QStandardItem);
1229  d->changeFlags(enabled, Qt::ItemIsEnabled);
1230 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.
#define enabled

◆ setFlags()

void QStandardItem::setFlags ( Qt::ItemFlags  flags)

Sets the item flags for the item to flags.

The item flags determine how the user can interact with the item. This is often used to disable an item.

See also
flags(), setData()

Definition at line 887 of file qstandarditemmodel.cpp.

Referenced by QStandardItemModelPrivate::QStandardItemModelPrivate(), and read().

888 {
889  setData((int)flags, Qt::UserRole - 1);
890 }
Qt::ItemFlags flags() const
Returns the item flags for the item.
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setFont()

void QStandardItem::setFont ( const QFont font)
inline

Sets the font used to display the item's text to the given font.

See also
font() setText() setForeground()

Definition at line 277 of file qstandarditemmodel.h.

278 { setData(afont, Qt::FontRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setForeground()

void QStandardItem::setForeground ( const QBrush brush)
inline

Sets the brush used to display the item's foreground (e.

g. text) to the given brush.

See also
foreground() setBackground() setFont()

Definition at line 286 of file qstandarditemmodel.h.

287 { setData(abrush, Qt::ForegroundRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setIcon()

void QStandardItem::setIcon ( const QIcon icon)
inline

Sets the item's icon to the icon specified.

Definition at line 256 of file qstandarditemmodel.h.

Referenced by QStandardItem().

257 { setData(aicon, Qt::DecorationRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setRowCount()

void QStandardItem::setRowCount ( int  rows)

Sets the number of child item rows to rows.

If this is less than rowCount(), the data in the unwanted rows is discarded.

See also
rowCount(), setColumnCount()

Definition at line 1502 of file qstandarditemmodel.cpp.

Referenced by insertColumn(), and QStandardItem().

1503 {
1504  int rc = rowCount();
1505  if (rc == rows)
1506  return;
1507  if (rc < rows)
1508  insertRows(qMax(rc, 0), rows - rc);
1509  else
1510  removeRows(qMax(rows, 0), rc - rows);
1511 }
void removeRows(int row, int count)
Removes count rows at row row.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int rowCount() const
Returns the number of child item rows that the item has.
void insertRows(int row, const QList< QStandardItem *> &items)
Inserts items at row.

◆ setSelectable()

void QStandardItem::setSelectable ( bool  selectable)

Sets whether the item is selectable.

If selectable is true, the item can be selected by the user; otherwise, the user cannot select the item.

You can control the selection behavior and mode by manipulating their view properties; see QAbstractItemView::selectionMode and QAbstractItemView::selectionBehavior.

See also
isSelectable(), setFlags()

Definition at line 1291 of file qstandarditemmodel.cpp.

1292 {
1293  Q_D(QStandardItem);
1294  d->changeFlags(selectable, Qt::ItemIsSelectable);
1295 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setSizeHint()

void QStandardItem::setSizeHint ( const QSize size)
inline

Sets the size hint for the item to be size.

If no size hint is set, the item delegate will compute the size hint based on the item data.

See also
sizeHint()

Definition at line 274 of file qstandarditemmodel.h.

275 { setData(asizeHint, Qt::SizeHintRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setStatusTip()

void QStandardItem::setStatusTip ( const QString statusTip)
inline

Sets the item's status tip to the string specified by statusTip.

See also
statusTip(), setToolTip(), setWhatsThis()

Definition at line 265 of file qstandarditemmodel.h.

266 { setData(astatusTip, Qt::StatusTipRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setText()

void QStandardItem::setText ( const QString text)
inline

Sets the item's text to the text specified.

See also
text(), setFont(), setForeground()

Definition at line 253 of file qstandarditemmodel.h.

Referenced by QStandardItem(), QStandardItemModel::setHorizontalHeaderLabels(), and QStandardItemModel::setVerticalHeaderLabels().

254 { setData(atext, Qt::DisplayRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setTextAlignment()

void QStandardItem::setTextAlignment ( Qt::Alignment  alignment)
inline

Sets the text alignment for the item's text to the alignment specified.

See also
textAlignment()

Definition at line 280 of file qstandarditemmodel.h.

281 { setData(int(atextAlignment), Qt::TextAlignmentRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setToolTip()

void QStandardItem::setToolTip ( const QString toolTip)
inline

Sets the item's tooltip to the string specified by toolTip.

See also
toolTip(), setStatusTip(), setWhatsThis()

Definition at line 260 of file qstandarditemmodel.h.

261 { setData(atoolTip, Qt::ToolTipRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ setTristate()

void QStandardItem::setTristate ( bool  tristate)

Sets whether the item is tristate.

If tristate is true, the item is checkable with three separate states; otherwise, the item is checkable with two states. (Note that this also requires that the item is checkable; see isCheckable().)

See also
isTristate(), setCheckable(), setCheckState()

Definition at line 1352 of file qstandarditemmodel.cpp.

1353 {
1354  Q_D(QStandardItem);
1355  d->changeFlags(tristate, Qt::ItemIsTristate);
1356 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ setWhatsThis()

void QStandardItem::setWhatsThis ( const QString whatsThis)
inline

Sets the item's "What's This?" help to the string specified by whatsThis.

See also
whatsThis(), setStatusTip(), setToolTip()

Definition at line 270 of file qstandarditemmodel.h.

271 { setData(awhatsThis, Qt::WhatsThisRole); }
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item&#39;s data for the given role to the specified value.

◆ sizeHint()

QSize QStandardItem::sizeHint ( ) const
inline

Returns the size hint set for the item, or an invalid QSize if no size hint has been set.

If no size hint has been set, the item delegate will compute the size hint based on the item data.

See also
setSizeHint()

Definition at line 109 of file qstandarditemmodel.h.

109  {
111  }
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ sortChildren()

void QStandardItem::sortChildren ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)

Sorts the children of the item using the given order, by the values in the given column.

Note
This function is recursive, therefore it sorts the children of the item, its grandchildren, etc.
See also
{operator<()}

Definition at line 1961 of file qstandarditemmodel.cpp.

1962 {
1963  Q_D(QStandardItem);
1964  if ((column < 0) || (rowCount() == 0))
1965  return;
1966  if (d->model)
1967  emit d->model->layoutAboutToBeChanged();
1968  d->sortChildren(column, order);
1969  if (d->model)
1970  emit d->model->layoutChanged();
1971 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
#define emit
Definition: qobjectdefs.h:76
int rowCount() const
Returns the number of child item rows that the item has.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ statusTip()

QString QStandardItem::statusTip ( ) const
inline

Returns the item's status tip.

See also
setStatusTip(), toolTip(), whatsThis()

Definition at line 96 of file qstandarditemmodel.h.

96  {
98  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ takeChild()

QStandardItem * QStandardItem::takeChild ( int  row,
int  column = 0 
)

Removes the child item at (row, column) without deleting it, and returns a pointer to the item.

If there was no child at the given location, then this function returns 0.

Note that this function, unlike takeRow() and takeColumn(), does not affect the dimensions of the child table.

See also
child(), takeRow(), takeColumn()

Definition at line 1830 of file qstandarditemmodel.cpp.

1831 {
1832  Q_D(QStandardItem);
1833  QStandardItem *item = 0;
1834  int index = d->childIndex(row, column);
1835  if (index != -1) {
1836  item = d->children.at(index);
1837  if (item)
1838  item->d_func()->setParentAndModel(0, 0);
1839  d->children.replace(index, 0);
1840  }
1841  return item;
1842 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
QModelIndex index() const
Returns the QModelIndex associated with this item.
The QStandardItem class provides an item for use with the QStandardItemModel class.

◆ takeColumn()

QList< QStandardItem * > QStandardItem::takeColumn ( int  column)

Removes column without deleting the column items, and returns a list of pointers to the removed items.

For items in the column that have not been set, the corresponding pointers in the list will be 0.

See also
removeColumn(), insertColumn(), takeRow()

Definition at line 1883 of file qstandarditemmodel.cpp.

1884 {
1885  Q_D(QStandardItem);
1886  if ((column < 0) || (column >= columnCount()))
1887  return QList<QStandardItem*>();
1888  if (d->model)
1889  d->model->d_func()->columnsAboutToBeRemoved(this, column, column);
1890  QList<QStandardItem*> items;
1891 
1892  for (int row = d->rowCount() - 1; row >= 0; --row) {
1893  int index = d->childIndex(row, column);
1894  QStandardItem *ch = d->children.at(index);
1895  if (ch)
1896  ch->d_func()->setParentAndModel(0, 0);
1897  d->children.remove(index);
1898  items.prepend(ch);
1899  }
1900  d->columns--;
1901  if (d->model)
1902  d->model->d_func()->columnsRemoved(this, column, 1);
1903  return items;
1904 }
double d
Definition: qnumeric_p.h:62
int columnCount() const
Returns the number of child item columns that the item has.
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
QModelIndex index() const
Returns the QModelIndex associated with this item.
The QStandardItem class provides an item for use with the QStandardItemModel class.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ takeRow()

QList< QStandardItem * > QStandardItem::takeRow ( int  row)

Removes row without deleting the row items, and returns a list of pointers to the removed items.

For items in the row that have not been set, the corresponding pointers in the list will be 0.

See also
removeRow(), insertRow(), takeColumn()

Definition at line 1851 of file qstandarditemmodel.cpp.

1852 {
1853  Q_D(QStandardItem);
1854  if ((row < 0) || (row >= rowCount()))
1855  return QList<QStandardItem*>();
1856  if (d->model)
1857  d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
1858  QList<QStandardItem*> items;
1859  int index = d->childIndex(row, 0); // Will return -1 if there are no columns
1860  if (index != -1) {
1861  int col_count = d->columnCount();
1862  for (int column = 0; column < col_count; ++column) {
1863  QStandardItem *ch = d->children.at(index + column);
1864  if (ch)
1865  ch->d_func()->setParentAndModel(0, 0);
1866  items.append(ch);
1867  }
1868  d->children.remove(index, col_count);
1869  }
1870  d->rows--;
1871  if (d->model)
1872  d->model->d_func()->rowsRemoved(this, row, 1);
1873  return items;
1874 }
double d
Definition: qnumeric_p.h:62
int row() const
Returns the row where the item is located in its parent&#39;s child table, or -1 if the item has no paren...
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int column() const
Returns the column where the item is located in its parent&#39;s child table, or -1 if the item has no pa...
QModelIndex index() const
Returns the QModelIndex associated with this item.
int rowCount() const
Returns the number of child item rows that the item has.
The QStandardItem class provides an item for use with the QStandardItemModel class.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ text()

QString QStandardItem::text ( ) const
inline

Returns the item's text.

This is the text that's presented to the user in a view.

See also
setText()

Definition at line 78 of file qstandarditemmodel.h.

78  {
80  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ textAlignment()

int QStandardItem::textAlignment ( ) const
inline

Returns the text alignment for the item's text.

Definition at line 119 of file qstandarditemmodel.h.

119  {
120  return Qt::Alignment(qvariant_cast<int>(data(Qt::TextAlignmentRole)));
121  }
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...

◆ toolTip()

QString QStandardItem::toolTip ( ) const
inline

Returns the item's tooltip.

See also
setToolTip(), statusTip(), whatsThis()

Definition at line 89 of file qstandarditemmodel.h.

89  {
91  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ type()

int QStandardItem::type ( ) const
virtual

Returns the type of this item.

The type is used to distinguish custom items from the base class. When subclassing QStandardItem, you should reimplement this function and return a new value greater than or equal to UserType .

See also
QStandardItem::Type

Definition at line 1995 of file qstandarditemmodel.cpp.

1996 {
1997  return Type;
1998 }

◆ whatsThis()

QString QStandardItem::whatsThis ( ) const
inline

Returns the item's "What's This?" help.

See also
setWhatsThis(), toolTip(), statusTip()

Definition at line 103 of file qstandarditemmodel.h.

103  {
105  }
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item&#39;s data for the given role, or an invalid QVariant if there is no data for the role...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ write()

void QStandardItem::write ( QDataStream out) const
virtual

Writes the item to stream out.

Only the data and flags of the item are written, not the child items.

See also
read()

Definition at line 2023 of file qstandarditemmodel.cpp.

Referenced by operator<<().

2024 {
2025  Q_D(const QStandardItem);
2026  out << d->values;
2027  out << flags();
2028 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::ItemFlags flags() const
Returns the item flags for the item.
The QStandardItem class provides an item for use with the QStandardItemModel class.

Friends and Related Functions

◆ operator<<()

QDataStream & operator<< ( QDataStream out,
const QStandardItem item 
)
related

Writes the QStandardItem item to stream out.

Since
4.2

This operator uses QStandardItem::write().

See also
{Serializing Qt Data Types}

Definition at line 2062 of file qstandarditemmodel.cpp.

2063 {
2064  item.write(out);
2065  return out;
2066 }
virtual void write(QDataStream &out) const
Writes the item to stream out.

◆ operator>>()

QDataStream & operator>> ( QDataStream in,
QStandardItem item 
)
related

Reads a QStandardItem from stream in into item.

Since
4.2

This operator uses QStandardItem::read().

See also
{Serializing Qt Data Types}

Definition at line 2043 of file qstandarditemmodel.cpp.

2044 {
2045  item.read(in);
2046  return in;
2047 }
virtual void read(QDataStream &in)
Reads the item from stream in.

◆ QStandardItemModel

friend class QStandardItemModel
friend

Definition at line 250 of file qstandarditemmodel.h.

◆ QStandardItemModelPrivate

Definition at line 249 of file qstandarditemmodel.h.

Properties

◆ d_ptr

QScopedPointer<QStandardItemPrivate> QStandardItem::d_ptr
protected

Definition at line 243 of file qstandarditemmodel.h.

Referenced by QStandardItemModel::mimeData().


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