QColumnView 类

QColumnView 类为列视图提供模型/视图实现。 更多...

头: #include <QColumnView>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QAbstractItemView

特性

公共函数

QColumnView (QWidget * parent = nullptr)
virtual ~QColumnView ()
QList<int> columnWidths () const
QWidget * previewWidget () const
bool resizeGripsVisible () const
void setColumnWidths (const QList<int> & list )
void setPreviewWidget (QWidget * widget )
void setResizeGripsVisible (bool visible )

重实现公共函数

virtual QModelIndex indexAt (const QPoint & point ) const override
virtual void scrollTo (const QModelIndex & index , QAbstractItemView::ScrollHint hint = EnsureVisible) override
virtual void selectAll () override
virtual void setModel (QAbstractItemModel * model ) override
virtual void setRootIndex (const QModelIndex & index ) override
virtual void setSelectionModel (QItemSelectionModel * newSelectionModel ) override
virtual QSize sizeHint () const override
virtual QRect visualRect (const QModelIndex & index ) const override

信号

void updatePreviewWidget (const QModelIndex & index )

保护函数

virtual QAbstractItemView * createColumn (const QModelIndex & index )
void initializeColumn (QAbstractItemView * column ) const

重实现保护函数

virtual void currentChanged (const QModelIndex & current , const QModelIndex & 上一 ) override
virtual int horizontalOffset () const override
virtual bool isIndexHidden (const QModelIndex & index ) const override
virtual QModelIndex moveCursor (QAbstractItemView::CursorAction cursorAction , Qt::KeyboardModifiers modifiers ) override
virtual void resizeEvent (QResizeEvent * event ) override
virtual void rowsInserted (const QModelIndex & parent , int start , int end ) override
virtual void scrollContentsBy (int dx , int dy ) override
virtual void setSelection (const QRect & rect , QItemSelectionModel::SelectionFlags 命令 ) override
virtual int verticalOffset () const override
virtual QRegion visualRegionForSelection (const QItemSelection & selection ) const override

详细描述

QColumnView displays a model in a number of QListViews, one for each hierarchy in the tree. This is sometimes referred to as a cascading list.

The QColumnView class is one of the 模型/视图类 且属于 Qt 的 模型/视图框架 .

QColumnView implements the interfaces defined by the QAbstractItemView 类以允许它显示提供数据,通过模型派生自 QAbstractItemModel 类。

另请参阅 模型/视图编程 .

特性文档编制

resizeGripsVisible : bool

This property holds the way to specify if the list views gets resize grips or not

默认情况下, visible is set to true

访问函数:

bool resizeGripsVisible () const
void setResizeGripsVisible (bool visible )

另请参阅 setRootIndex ().

成员函数文档编制

[explicit] QColumnView:: QColumnView ( QWidget * parent = nullptr)

构造列视图采用 parent 来表示模型数据。使用 setModel () 来设置模型。

另请参阅 QAbstractItemModel .

[virtual noexcept] QColumnView:: ~QColumnView ()

销毁列视图。

QList < int > QColumnView:: columnWidths () const

Returns a list of the width of all the columns in this view.

另请参阅 setColumnWidths ().

[virtual protected] QAbstractItemView *QColumnView:: createColumn (const QModelIndex & index )

To use a custom widget for the final column when you select an item overload this function and return a widget. index is the root index that will be assigned to the view.

Return the new view. QColumnView will automatically take ownership of the widget.

另请参阅 setPreviewWidget ().

[override virtual protected] void QColumnView:: currentChanged (const QModelIndex & current , const QModelIndex & 上一 )

重实现: QAbstractItemView::currentChanged (const QModelIndex ¤t, const QModelIndex &previous).

[override virtual protected] int QColumnView:: horizontalOffset () const

重实现: QAbstractItemView::horizontalOffset() const .

[override virtual] QModelIndex QColumnView:: indexAt (const QPoint & point ) const

重实现: QAbstractItemView::indexAt(const QPoint &point) const .

[protected] void QColumnView:: initializeColumn ( QAbstractItemView * column ) const

Copies the behavior and options of the column view and applies them to the column such as the iconSize (), textElideMode () 和 alternatingRowColors (). This can be useful when reimplementing createColumn ().

另请参阅 createColumn ().

[override virtual protected] bool QColumnView:: isIndexHidden (const QModelIndex & index ) const

重实现: QAbstractItemView::isIndexHidden(const QModelIndex &index) const .

[override virtual protected] QModelIndex QColumnView:: moveCursor ( QAbstractItemView::CursorAction cursorAction , Qt::KeyboardModifiers modifiers )

重实现: QAbstractItemView::moveCursor (QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers).

Move left should go to the parent index Move right should go to the child index or down if there is no child

QWidget *QColumnView:: previewWidget () const

Returns the preview widget, or nullptr 若没有。

另请参阅 setPreviewWidget () 和 updatePreviewWidget ().

[override virtual protected] void QColumnView:: resizeEvent ( QResizeEvent * event )

重实现: QAbstractItemView::resizeEvent (QResizeEvent *event).

[override virtual protected] void QColumnView:: rowsInserted (const QModelIndex & parent , int start , int end )

重实现: QAbstractItemView::rowsInserted (const QModelIndex &parent, int start, int end).

[override virtual protected] void QColumnView:: scrollContentsBy ( int dx , int dy )

重实现: QAbstractScrollArea::scrollContentsBy (int dx, int dy).

[override virtual] void QColumnView:: scrollTo (const QModelIndex & index , QAbstractItemView::ScrollHint hint = EnsureVisible)

重实现: QAbstractItemView::scrollTo (const QModelIndex &index, QAbstractItemView::ScrollHint hint).

[override virtual] void QColumnView:: selectAll ()

重实现: QAbstractItemView::selectAll ().

void QColumnView:: setColumnWidths (const QList < int > & list )

Sets the column widths to the values given in the list . Extra values in the list are kept and used when the columns are created.

If list contains too few values, only width of the rest of the columns will not be modified.

另请参阅 columnWidths () 和 createColumn ().

[override virtual] void QColumnView:: setModel ( QAbstractItemModel * model )

重实现: QAbstractItemView::setModel (QAbstractItemModel *model).

void QColumnView:: setPreviewWidget ( QWidget * widget )

设置预览 widget .

The widget becomes a child of the column view, and will be destroyed when the column area is deleted or when a new widget is set.

另请参阅 previewWidget () 和 updatePreviewWidget ().

[override virtual] void QColumnView:: setRootIndex (const QModelIndex & index )

重实现: QAbstractItemView::setRootIndex (const QModelIndex &index).

[override virtual protected] void QColumnView:: setSelection (const QRect & rect , QItemSelectionModel::SelectionFlags 命令 )

重实现: QAbstractItemView::setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags flags).

[override virtual] void QColumnView:: setSelectionModel ( QItemSelectionModel * newSelectionModel )

重实现: QAbstractItemView::setSelectionModel (QItemSelectionModel *selectionModel).

[override virtual] QSize QColumnView:: sizeHint () const

重实现: QAbstractScrollArea::sizeHint() const .

[signal] void QColumnView:: updatePreviewWidget (const QModelIndex & index )

This signal is emitted when the preview widget should be updated to provide rich information about index

另请参阅 previewWidget ().

[override virtual protected] int QColumnView:: verticalOffset () const

重实现: QAbstractItemView::verticalOffset() const .

[override virtual] QRect QColumnView:: visualRect (const QModelIndex & index ) const

重实现: QAbstractItemView::visualRect(const QModelIndex &index) const .

[override virtual protected] QRegion QColumnView:: visualRegionForSelection (const QItemSelection & selection ) const

重实现: QAbstractItemView::visualRegionForSelection(const QItemSelection &selection) const .