📄 qstandarditemmodel.cpp
字号:
Sets the item's background brush to the specified \a brush. \sa background() setForeground()*//*! \fn QBrush QStandardItem::foreground() const Returns the brush used to render the item's foreground (e.g. text). \sa setForeground() background()*//*! \fn void QStandardItem::setForeground(const QBrush &brush) Sets the brush used to display the item's foreground (e.g. text) to the given \a brush. \sa foreground() setBackground() setFont()*//*! \fn int QStandardItem::textAlignment() const Returns the text alignment for the item's text.*//*! \fn void QStandardItem::setTextAlignment(Qt::Alignment alignment) Sets the text alignment for the item's text to the \a alignment specified. \sa textAlignment()*//*! \fn QSize QStandardItem::sizeHint() const 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. \sa setSizeHint()*//*! \fn void QStandardItem::setSizeHint(const QSize &size) Sets the size hint for the item to be \a size. If no size hint is set, the item delegate will compute the size hint based on the item data. \sa sizeHint()*//*! \fn Qt::CheckState QStandardItem::checkState() const Returns the checked state of the item. \sa setCheckState(), isCheckable()*//*! \fn void QStandardItem::setCheckState(Qt::CheckState state) Sets the check state of the item to be \a state. \sa checkState(), setCheckable()*//*! \fn QString QStandardItem::accessibleText() const 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). \sa setAccessibleText(), accessibleDescription()*//*! \fn void QStandardItem::setAccessibleText(const QString &accessibleText) Sets the item's accessible text to the string specified by \a accessibleText. The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction). \sa accessibleText(), setAccessibleDescription()*//*! \fn QString QStandardItem::accessibleDescription() const 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). \sa setAccessibleDescription(), accessibleText()*//*! \fn void QStandardItem::setAccessibleDescription(const QString &accessibleDescription) Sets the item's accessible description to the string specified by \a accessibleDescription. The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction). \sa accessibleDescription(), setAccessibleText()*//*! Sets whether the item is enabled. If \a enabled is true, the item is enabled, meaning that the user can interact with the item; if \a enabled is false, the user cannot interact with the item. This flag takes presedence 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. \sa isEnabled(), Qt::ItemIsEnabled, setFlags()*/void QStandardItem::setEnabled(bool enabled){ Q_D(QStandardItem); d->changeFlags(enabled, Qt::ItemIsEnabled);}/*! \fn bool QStandardItem::isEnabled() const 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. \sa setEnabled(), flags()*//*! Sets whether the item is editable. If \a 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. \sa isEditable(), setFlags()*/void QStandardItem::setEditable(bool editable){ Q_D(QStandardItem); d->changeFlags(editable, Qt::ItemIsEditable);}/*! \fn bool QStandardItem::isEditable() const 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. \sa setEditable(), flags()*//*! Sets whether the item is selectable. If \a 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. \sa isSelectable(), setFlags()*/void QStandardItem::setSelectable(bool selectable){ Q_D(QStandardItem); d->changeFlags(selectable, Qt::ItemIsSelectable);}/*! \fn bool QStandardItem::isSelectable() const Returns whether the item is selectable by the user. The default value is true. \sa setSelectable(), flags()*//*! Sets whether the item is user-checkable. If \a 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. \sa isCheckable(), setCheckState(), setTristate()*/void QStandardItem::setCheckable(bool checkable){ Q_D(QStandardItem); if (checkable && !isCheckable()) { // make sure there's data for the checkstate role if (!data(Qt::CheckStateRole).isValid()) setData(Qt::Unchecked, Qt::CheckStateRole); } d->changeFlags(checkable, Qt::ItemIsUserCheckable);}/*! \fn bool QStandardItem::isCheckable() const Returns whether the item is user-checkable. The default value is false. \sa setCheckable(), checkState(), isTristate()*//*! Sets whether the item is tristate. If \a 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().) \sa isTristate(), setCheckable(), setCheckState()*/void QStandardItem::setTristate(bool tristate){ Q_D(QStandardItem); d->changeFlags(tristate, Qt::ItemIsTristate);}/*! \fn bool QStandardItem::isTristate() const Returns whether the item is tristate; that is, if it's checkable with tree separate states. The default value is false. \sa setTristate(), isCheckable(), checkState()*/#ifndef QT_NO_DRAGANDDROP/*! Sets whether the item is drag enabled. If \a 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. \sa isDragEnabled(), setDropEnabled(), setFlags()*/void QStandardItem::setDragEnabled(bool dragEnabled){ Q_D(QStandardItem); d->changeFlags(dragEnabled, Qt::ItemIsDragEnabled);}/*! \fn bool QStandardItem::isDragEnabled() const 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. \sa setDragEnabled(), isDropEnabled(), flags()*//*! Sets whether the item is drop enabled. If \a 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(). \sa isDropEnabled(), setDragEnabled(), setFlags()*/void QStandardItem::setDropEnabled(bool dropEnabled){ Q_D(QStandardItem); d->changeFlags(dropEnabled, Qt::ItemIsDropEnabled);}/*! \fn bool QStandardItem::isDropEnabled() const 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. \sa setDropEnabled(), isDragEnabled(), flags()*/#endif // QT_NO_DRAGANDDROP/*! Returns the row where the item is located in its parent's child table, or -1 if the item has no parent. \sa column(), parent()*/int QStandardItem::row() const{ Q_D(const QStandardItem); QPair<int, int> pos = d->position(); return pos.first;}/*! Returns the column where the item is located in its parent's child table, or -1 if the item has no parent. \sa row(), parent()*/int QStandardItem::column() const{ Q_D(const QStandardItem); QPair<int, int> pos = d->position(); return pos.second;}/*! 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. \sa model(), QStandardItemModel::itemFromIndex()*/QModelIndex QStandardItem::index() const{ Q_D(const QStandardItem); return d->model ? d->model->indexFromItem(this) : QModelIndex();}/*! 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. \sa index()*/QStandardItemModel *QStandardItem::model() const{ Q_D(const QStandardItem); return d->model;}/*! Sets the number of child item rows to \a rows. If this is less than rowCount(), the data in the unwanted rows is discarded. \sa rowCount(), setColumnCount()*/void QStandardItem::setRowCount(int rows){ int rc = rowCount(); if (rc == rows) return; if (rc < rows) insertRows(qMax(rc, 0), rows - rc); else removeRows(qMax(rows, 0), rc - rows);}/*! Returns the number of child item rows that the item has. \sa setRowCount(), columnCount()*/int QStandardItem::rowCount() const{ Q_D(const QStandardItem); return d->rowCount();}/*! Sets the number of child item columns to \a columns. If this is less than columnCount(), the data in the unwanted columns is discarded. \sa columnCount(), setRowCount()*/void QStandardItem::setColumnCount(int columns){ int cc = columnCount(); if (cc == columns) return; if (cc < columns) insertColumns(qMax(cc, 0), columns - cc); else removeColumns(qMax(columns, 0), cc - columns);}/*! Returns the number of child item columns that the item has. \sa setColumnCount(), rowCount()*/int QStandardItem::columnCount() const{ Q_D(const QStandardItem); return d->columnCount();}/*! Inserts a row at \a row containing \a items. If necessary, the column count is increased to the size of \a items. \sa insertRows(), insertColumn()*/void QStandardItem::insertRow(int row, const QList<QStandardItem*> &items){ Q_D(QStandardItem); if (row < 0) return; if (columnCount() < items.count()) setColumnCount(items.count()); d->insertRows(row, 1, items);}/*! Inserts \a items at \a row. The column count wont be changed. \sa insertRow(), insertColumn()*/void QStandardItem::insertRows(int row, const QList<QStandardItem*> &items){ Q_D(QStandardItem); if (row < 0) return; d->insertRows(row, items);}/*! Inserts a column at \a column containing \a items. If necessary, the row count is increased to the size of \a items. \sa insertColumns(), insertRow()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -