📄 qabstractitemview.cpp
字号:
Q_D(const QAbstractItemView); return d->columnDelegates.value(column, 0);}/*! Returns the item delegate used by this view and model for the given \a index.*/QAbstractItemDelegate *QAbstractItemView::itemDelegate(const QModelIndex &index) const{ Q_D(const QAbstractItemView); return d->delegateForIndex(index);}/*! \property QAbstractItemView::selectionMode \brief which selection mode the view operates in This property controls whether the user can select one or many items and, in many-item selections, whether the selection must be a continuous range of items. \sa SelectionMode SelectionBehavior*/void QAbstractItemView::setSelectionMode(SelectionMode mode){ Q_D(QAbstractItemView); d->selectionMode = mode;}QAbstractItemView::SelectionMode QAbstractItemView::selectionMode() const{ Q_D(const QAbstractItemView); return d->selectionMode;}/*! \property QAbstractItemView::selectionBehavior \brief which selection behavior the view uses This property holds whether selections are done in terms of single items, rows or columns. \sa SelectionMode SelectionBehavior*/void QAbstractItemView::setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior){ Q_D(QAbstractItemView); d->selectionBehavior = behavior;}QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior() const{ Q_D(const QAbstractItemView); return d->selectionBehavior;}/*! Sets the current item to be the item at \a index. Depending on the current selection mode, the item may also be selected. Note that this function also updates the starting position for any new selections the user performs. To set an item as the current item without selecting it, call \c{selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);} \sa currentIndex(), currentChanged(), selectionMode*/void QAbstractItemView::setCurrentIndex(const QModelIndex &index){ Q_D(QAbstractItemView); if (d->selectionModel) { QItemSelectionModel::SelectionFlags command = selectionCommand(index, 0); d->selectionModel->setCurrentIndex(index, command); d->currentIndexSet = true; if ((command & QItemSelectionModel::Current) == 0) d->pressedPosition = visualRect(currentIndex()).center() + d->offset(); }}/*! Returns the model index of the current item. \sa setCurrentIndex()*/QModelIndex QAbstractItemView::currentIndex() const{ Q_D(const QAbstractItemView); return d->selectionModel ? d->selectionModel->currentIndex() : QModelIndex();}/*! Reset the internal state of the view.*/void QAbstractItemView::reset(){ Q_D(QAbstractItemView); _q_abstractitemview_editor_const_iterator it = d->editors.constBegin(); for (; it != d->editors.constEnd(); ++it) d->releaseEditor(d->editorForIterator(it)); d->editors.clear(); d->persistent.clear(); d->currentIndexSet = false; setState(NoState); setRootIndex(QModelIndex());}/*! Sets the root item to the item at the given \a index. \sa rootIndex()*/void QAbstractItemView::setRootIndex(const QModelIndex &index){ Q_D(QAbstractItemView); Q_ASSERT_X(index.isValid() ? index.model() == d->model : true, "QAbstractItemView::setRootIndex", "index must be from the currently set model"); d->root = index; d->doDelayedItemsLayout();}/*! Returns the model index of the model's root item. The root item is the parent item to the view's toplevel items. The root can be invalid. \sa setRootIndex()*/QModelIndex QAbstractItemView::rootIndex() const{ return QModelIndex(d_func()->root);}/*! Selects all non-hidden items. \sa setSelection(), selectedIndexes(), clearSelection()*/void QAbstractItemView::selectAll(){ Q_D(QAbstractItemView); d->selectAll(selectionCommand(d->model->index(0, 0, d->root)));}/*! Starts editing the item corresponding to the given \a index if it is editable. Note that this function does not change the current index. Since the current index defines the next and previous items to edit, users may find that keyboard navigation does not work as expected. To provide consistent navigation behavior, call setCurrentIndex() before this function with the same model index. \sa QModelIndex::flags()*/void QAbstractItemView::edit(const QModelIndex &index){ Q_D(QAbstractItemView); if (!d->isIndexValid(index)) qWarning("edit: index was invalid"); if (!edit(index, AllEditTriggers, 0)) qWarning("edit: editing failed");}/*! Clears all selected items. The current index will not be changed. \sa setSelection(), selectAll()*/void QAbstractItemView::clearSelection(){ Q_D(QAbstractItemView); if (d->selectionModel) d->selectionModel->clearSelection();}/*! \internal This function is intended to lay out the items in the view. The default implementatiidon just calls updateGeometries() and updates the viewport.*/void QAbstractItemView::doItemsLayout(){ Q_D(QAbstractItemView); d->delayedLayout.stop(); updateGeometries(); d->viewport->update();}/*! \property QAbstractItemView::editTriggers \brief which actions will initiate item editing This property is a selection of flags defined by \l{EditTrigger}, combined using the OR operator. The view will only initiate the editing of an item if the action performed is set in this property.*/void QAbstractItemView::setEditTriggers(EditTriggers actions){ Q_D(QAbstractItemView); d->editTriggers = actions;}QAbstractItemView::EditTriggers QAbstractItemView::editTriggers() const{ Q_D(const QAbstractItemView); return d->editTriggers;}/*! \since 4.2 \property QAbstractItemView::verticalScrollMode \brief how the view scrolls its contents in the vertical direction This property controlls how the view scroll its contents vertically. Scrolling can be done either per pixel or per item.*/void QAbstractItemView::setVerticalScrollMode(ScrollMode mode){ Q_D(QAbstractItemView); d->verticalScrollMode = mode; updateGeometries(); // update the scroll bars}QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode() const{ Q_D(const QAbstractItemView); return d->verticalScrollMode;}/*! \since 4.2 \property QAbstractItemView::horizontalScrollMode \brief how the view scrolls its contents in the horizontal direction This property controlls how the view scroll its contents horizontally. Scrolling can be done either per pixel or per item.*/void QAbstractItemView::setHorizontalScrollMode(ScrollMode mode){ Q_D(QAbstractItemView); d->horizontalScrollMode = mode; updateGeometries(); // update the scroll bars}QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode() const{ Q_D(const QAbstractItemView); return d->horizontalScrollMode;}#ifndef QT_NO_DRAGANDDROP/*! \since 4.2 \property QAbstractItemView::dragDropOverwriteMode \brief the view's drag and drop behavior If its value is \c true, the selected data will overwrite the existing item data when dropped, while moving the data will clear the item. If its value is \c false, the selected data will be inserted as a new item when the data is dropped. When the data is moved, the item is removed as well. The default value is \c false, as in the QListView and QTreeView subclasses. In the QTableView subclass, on the other hand, the property has been set to \c true. \sa dragDropMode*/void QAbstractItemView::setDragDropOverwriteMode(bool overwrite){ Q_D(QAbstractItemView); d->overwrite = overwrite;}bool QAbstractItemView::dragDropOverwriteMode() const{ Q_D(const QAbstractItemView); return d->overwrite;}#endif/*! \property QAbstractItemView::autoScroll \brief whether autoscrolling in drag move events is enabled If this property is set to true (the default), the QAbstractItemView automatically scrolls the contents of the view if the user drags within 16 pixels of the viewport edge. This only works if the viewport accepts drops. Autoscroll is switched off by setting this property to false.*/void QAbstractItemView::setAutoScroll(bool enable){ Q_D(QAbstractItemView); d->autoScroll = enable;}bool QAbstractItemView::hasAutoScroll() const{ Q_D(const QAbstractItemView); return d->autoScroll;}/*! \property QAbstractItemView::tabKeyNavigation \brief whether item navigation with tab and backtab is enabled.*/void QAbstractItemView::setTabKeyNavigation(bool enable){ Q_D(QAbstractItemView); d->tabKeyNavigation = enable;}bool QAbstractItemView::tabKeyNavigation() const{ Q_D(const QAbstractItemView); return d->tabKeyNavigation;}#ifndef QT_NO_DRAGANDDROP/*! \property QAbstractItemView::showDropIndicator \brief whether the drop indicator is shown when dragging items and dropping. \sa dragEnabled DragDropMode dragDropOverwriteMode acceptDrops*/void QAbstractItemView::setDropIndicatorShown(bool enable){ Q_D(QAbstractItemView); d->showDropIndicator = enable;}bool QAbstractItemView::showDropIndicator() const{ Q_D(const QAbstractItemView); return d->showDropIndicator;}/*! \property QAbstractItemView::dragEnabled \brief whether the view supports dragging of its own items \sa showDropIndicator DragDropMode dragDropOverwriteMode acceptDrops*/void QAbstractItemView::setDragEnabled(bool enable){ Q_D(QAbstractItemView); d->dragEnabled = enable;}bool QAbstractItemView::dragEnabled() const{ Q_D(const QAbstractItemView); return d->dragEnabled;}/*! \since 4.2 \enum QAbstractItemView::DragDropMode Describes the various drag and drop events the view can act upon. By default the view does not support dragging or dropping (\c NoDragDrop). \value NoDragDrop Does not support dragging or dropping. \value DragOnly The view supports dragging of its own items \value DropOnly The view accepts drops \value DragDrop The view supports both dragging and dropping \value InternalMove only accepts move operations only from itself. Note that the model used needs to provide support for drag and drop operations. \sa setDragDropMode() {Using Drag and Drop with Item Views}*//*! \property QAbstractItemView::dragDropMode \brief the drag and drop event the view will act upon
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -