Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QColumnView Class Reference

#include <qcolumnview.h>

+ Inheritance diagram for QColumnView:
+ Collaboration diagram for QColumnView:

Signals

void updatePreviewWidget (const QModelIndex &index)
 
- Signals inherited from QAbstractItemView
void pressed (const QModelIndex &index)
 This signal is emitted when a mouse button is pressed.
 
void clicked (const QModelIndex &index)
 This signal is emitted when a mouse button is left-clicked.
 
void doubleClicked (const QModelIndex &index)
 This signal is emitted when a mouse button is double-clicked.
 
void activated (const QModelIndex &index)
 This signal is emitted when the item specified by index is activated by the user.
 
void entered (const QModelIndex &index)
 This signal is emitted when the mouse cursor enters the item specified by index.
 
void viewportEntered ()
 This signal is emitted when the mouse cursor enters the viewport.
 
void iconSizeChanged (const QSize &size)
 

Public Member Functions

 QColumnView (QWidget *parent=nullptr)
 
 ~QColumnView ()
 
QModelIndex indexAt (const QPoint &point) const override
 Returns the model index of the item at the viewport coordinates point.
 
void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible) override
 Scrolls the view if necessary to ensure that the item at index is visible.
 
QSize sizeHint () const override
 
QRect visualRect (const QModelIndex &index) const override
 Returns the rectangle on the viewport occupied by the item at index.
 
void setModel (QAbstractItemModel *model) override
 Sets the model for the view to present.
 
void setSelectionModel (QItemSelectionModel *selectionModel) override
 Sets the current selection model to the given selectionModel.
 
void setRootIndex (const QModelIndex &index) override
 Sets the root item to the item at the given index.
 
void selectAll () override
 Selects all items in the view.
 
void setResizeGripsVisible (bool visible)
 
bool resizeGripsVisible () const
 
QWidgetpreviewWidget () const
 
void setPreviewWidget (QWidget *widget)
 
void setColumnWidths (const QList< int > &list)
 
QList< int > columnWidths () const
 
- Public Member Functions inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 Constructs an abstract item view with the given parent.
 
 ~QAbstractItemView ()
 Destroys the view.
 
QAbstractItemModelmodel () const
 Returns the model that this view is presenting.
 
QItemSelectionModelselectionModel () const
 Returns the current selection model.
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate for this view and its model to delegate.
 
QAbstractItemDelegateitemDelegate () const
 Returns the item delegate used by this view and model.
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
QAbstractItemView::SelectionMode selectionMode () const
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QModelIndex currentIndex () const
 Returns the model index of the current item.
 
QModelIndex rootIndex () const
 Returns the model index of the model's root item.
 
void setEditTriggers (EditTriggers triggers)
 
EditTriggers editTriggers () const
 
void setVerticalScrollMode (ScrollMode mode)
 
ScrollMode verticalScrollMode () const
 
void resetVerticalScrollMode ()
 
void setHorizontalScrollMode (ScrollMode mode)
 
ScrollMode horizontalScrollMode () const
 
void resetHorizontalScrollMode ()
 
void setAutoScroll (bool enable)
 
bool hasAutoScroll () const
 
void setAutoScrollMargin (int margin)
 
int autoScrollMargin () const
 
void setTabKeyNavigation (bool enable)
 
bool tabKeyNavigation () const
 
void setAlternatingRowColors (bool enable)
 
bool alternatingRowColors () const
 
void setIconSize (const QSize &size)
 
QSize iconSize () const
 
void setTextElideMode (Qt::TextElideMode mode)
 
Qt::TextElideMode textElideMode () const
 
virtual void keyboardSearch (const QString &search)
 Moves to and selects the item best matching the string search.
 
QSize sizeHintForIndex (const QModelIndex &index) const
 Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
 
virtual int sizeHintForRow (int row) const
 Returns the height size hint for the specified row or -1 if there is no model.
 
virtual int sizeHintForColumn (int column) const
 Returns the width size hint for the specified column or -1 if there is no model.
 
void openPersistentEditor (const QModelIndex &index)
 Opens a persistent editor on the item at the given index.
 
void closePersistentEditor (const QModelIndex &index)
 Closes the persistent editor for the item at the given index.
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
QWidgetindexWidget (const QModelIndex &index) const
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
virtual QAbstractItemDelegateitemDelegateForIndex (const QModelIndex &index) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 \reimp
 

Protected Member Functions

 QColumnView (QColumnViewPrivate &dd, QWidget *parent=nullptr)
 
bool isIndexHidden (const QModelIndex &index) const override
 Returns true if the item referred to by the given index is hidden in the view, otherwise returns false.
 
QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
 Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers.
 
void resizeEvent (QResizeEvent *event) override
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command) override
 Applies the selection flags to the items in or touched by the rectangle, rect.
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 Returns the region from the viewport of the items in the given selection.
 
int horizontalOffset () const override
 Returns the horizontal offset of the view.
 
int verticalOffset () const override
 Returns the vertical offset of the view.
 
void rowsInserted (const QModelIndex &parent, int start, int end) override
 This slot is called when rows are inserted.
 
void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 This slot is called when a new item becomes the current item.
 
void scrollContentsBy (int dx, int dy) override
 
virtual QAbstractItemViewcreateColumn (const QModelIndex &rootIndex)
 
void initializeColumn (QAbstractItemView *column) const
 
- Protected Member Functions inherited from QAbstractItemView
 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr)
 
virtual QModelIndexList selectedIndexes () const
 This convenience function returns a list of all selected and non-hidden item indexes in the view.
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 Starts editing the item at index, creating an editor if necessary, and returns true if the view's \l{State} is now EditingState; otherwise returns false.
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 Returns the SelectionFlags to be used when updating a selection model for the specified index.
 
virtual void initViewItemOption (QStyleOptionViewItem *option) const
 
State state () const
 Returns the item view's state.
 
void setState (State state)
 Sets the item view's state to the given state.
 
void scheduleDelayedItemsLayout ()
 Schedules a layout of the items in the view to be executed when the event processing starts.
 
void executeDelayedItemsLayout ()
 Executes the scheduled layouts without waiting for the event processing to begin.
 
void setDirtyRegion (const QRegion &region)
 
void scrollDirtyRegion (int dx, int dy)
 Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction.
 
QPoint dirtyRegionOffset () const
 Returns the offset of the dirty regions in the view.
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void doAutoScroll ()
 
bool focusNextPrevChild (bool next) override
 \reimp
 
bool event (QEvent *event) override
 \reimp
 
bool viewportEvent (QEvent *event) override
 This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis.
 
void mousePressEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is pressed while the cursor is inside the widget.
 
void mouseMoveEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse move event is sent to the widget.
 
void mouseReleaseEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is released, after a mouse press event on the widget.
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is double clicked inside the widget.
 
void focusInEvent (QFocusEvent *event) override
 This function is called with the given event when the widget obtains the focus.
 
void focusOutEvent (QFocusEvent *event) override
 This function is called with the given event when the widget loses the focus.
 
void keyPressEvent (QKeyEvent *event) override
 This function is called with the given event when a key event is sent to the widget.
 
void resizeEvent (QResizeEvent *event) override
 This function is called with the given event when a resize event is sent to the widget.
 
void timerEvent (QTimerEvent *event) override
 This function is called with the given event when a timer event is sent to the widget.
 
void inputMethodEvent (QInputMethodEvent *event) override
 \reimp
 
bool eventFilter (QObject *object, QEvent *event) override
 \reimp
 
QSize viewportSizeHint () const override
 

Properties

bool resizeGripsVisible
 
- Properties inherited from QAbstractItemView
bool autoScroll
 whether autoscrolling in drag move events is enabled
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered
 
EditTriggers editTriggers
 which actions will initiate item editing
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled.
 
bool alternatingRowColors
 whether to draw the background using alternating colors
 
SelectionMode selectionMode
 which selection mode the view operates in
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses
 
QSize iconSize
 the size of items' icons
 
Qt::TextElideMode textElideMode
 the position of the "..." in elided text.
 
ScrollMode verticalScrollMode
 how the view scrolls its contents in the vertical direction
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction
 

Additional Inherited Members

- Public Types inherited from QAbstractItemView
enum  SelectionMode {
  NoSelection , SingleSelection , MultiSelection , ExtendedSelection ,
  ContiguousSelection
}
 This enum indicates how the view responds to user selections: More...
 
enum  SelectionBehavior { SelectItems , SelectRows , SelectColumns }
 \value SelectItems Selecting single items. More...
 
enum  ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter }
 \value EnsureVisible Scroll to ensure that the item is visible. More...
 
enum  EditTrigger {
  NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 ,
  EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31
}
 This enum describes actions which will initiate item editing. More...
 
enum  ScrollMode { ScrollPerItem , ScrollPerPixel }
 
- Public Slots inherited from QAbstractItemView
virtual void reset ()
 Reset the internal state of the view.
 
virtual void doItemsLayout ()
 
void edit (const QModelIndex &index)
 Starts editing the item corresponding to the given index if it is editable.
 
void clearSelection ()
 Deselects all selected items.
 
void setCurrentIndex (const QModelIndex &index)
 Sets the current item to be the item at index.
 
void scrollToTop ()
 
void scrollToBottom ()
 
void update (const QModelIndex &index)
 
- Protected Types inherited from QAbstractItemView
enum  CursorAction {
  MoveUp , MoveDown , MoveLeft , MoveRight ,
  MoveHome , MoveEnd , MovePageUp , MovePageDown ,
  MoveNext , MovePrevious
}
 This enum describes the different ways to navigate between items,. More...
 
enum  State {
  NoState , DraggingState , DragSelectingState , EditingState ,
  ExpandingState , CollapsingState , AnimatingState
}
 Describes the different states the view can be in. More...
 
- Protected Slots inherited from QAbstractItemView
virtual void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
 This slot is called when items with the given roles are changed in the model.
 
virtual void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 This slot is called when rows are about to be removed.
 
virtual void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 This slot is called when the selection is changed.
 
virtual void updateEditorData ()
 
virtual void updateEditorGeometries ()
 
virtual void updateGeometries ()
 
virtual void verticalScrollbarAction (int action)
 
virtual void horizontalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 Closes the given editor, and releases it.
 
virtual void commitData (QWidget *editor)
 Commit the data in the editor to the model.
 
virtual void editorDestroyed (QObject *editor)
 This function is called when the given editor has been destroyed.
 

Detailed Description

Definition at line 16 of file qcolumnview.h.

Constructor & Destructor Documentation

◆ QColumnView() [1/2]

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

◆ ~QColumnView()

QColumnView::~QColumnView ( )

◆ QColumnView() [2/2]

QColumnView::QColumnView ( QColumnViewPrivate & dd,
QWidget * parent = nullptr )
protected

Member Function Documentation

◆ columnWidths()

QList< int > QColumnView::columnWidths ( ) const

◆ createColumn()

virtual QAbstractItemView * QColumnView::createColumn ( const QModelIndex & rootIndex)
protectedvirtual

◆ currentChanged()

void QColumnView::currentChanged ( const QModelIndex & current,
const QModelIndex & previous )
overrideprotectedvirtual

This slot is called when a new item becomes the current item.

The previous current item is specified by the previous index, and the new item by the current index.

If you want to know about changes to items see the dataChanged() signal.

Reimplemented from QAbstractItemView.

◆ horizontalOffset()

int QColumnView::horizontalOffset ( ) const
overrideprotectedvirtual

Returns the horizontal offset of the view.

In the base class this is a pure virtual function.

See also
verticalOffset()

Implements QAbstractItemView.

◆ indexAt()

QModelIndex QColumnView::indexAt ( const QPoint & point) const
overridevirtual

Returns the model index of the item at the viewport coordinates point.

In the base class this is a pure virtual function.

See also
visualRect()

Implements QAbstractItemView.

◆ initializeColumn()

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

◆ isIndexHidden()

bool QColumnView::isIndexHidden ( const QModelIndex & index) const
overrideprotectedvirtual

Returns true if the item referred to by the given index is hidden in the view, otherwise returns false.

Hiding is a view specific feature. For example in TableView a column can be marked as hidden or a row in the TreeView.

In the base class this is a pure virtual function.

Implements QAbstractItemView.

◆ moveCursor()

QModelIndex QColumnView::moveCursor ( CursorAction cursorAction,
Qt::KeyboardModifiers modifiers )
overrideprotectedvirtual

Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers.

In the base class this is a pure virtual function.

Implements QAbstractItemView.

◆ previewWidget()

QWidget * QColumnView::previewWidget ( ) const

◆ resizeEvent()

void QColumnView::resizeEvent ( QResizeEvent * event)
overrideprotected

◆ resizeGripsVisible()

bool QColumnView::resizeGripsVisible ( ) const

◆ rowsInserted()

void QColumnView::rowsInserted ( const QModelIndex & parent,
int start,
int end )
overrideprotectedvirtual

This slot is called when rows are inserted.

The new rows are those under the given parent from start to end inclusive. The base class implementation calls fetchMore() on the model to check for more data.

See also
rowsAboutToBeRemoved()

Reimplemented from QAbstractItemView.

◆ scrollContentsBy()

void QColumnView::scrollContentsBy ( int dx,
int dy )
overrideprotected

◆ scrollTo()

void QColumnView::scrollTo ( const QModelIndex & index,
ScrollHint hint = EnsureVisible )
overridevirtual

Scrolls the view if necessary to ensure that the item at index is visible.

The view will try to position the item according to the given hint.

In the base class this is a pure virtual function.

Implements QAbstractItemView.

◆ selectAll()

void QColumnView::selectAll ( )
overridevirtual

Selects all items in the view.

This function will use the selection behavior set on the view when selecting.

See also
setSelection(), selectedIndexes(), clearSelection()

Reimplemented from QAbstractItemView.

◆ setColumnWidths()

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

◆ setModel()

void QColumnView::setModel ( QAbstractItemModel * model)
overridevirtual

Sets the model for the view to present.

This function will create and set a new selection model, replacing any model that was previously set with setSelectionModel(). However, the old selection model will not be deleted as it may be shared between several views. We recommend that you delete the old selection model if it is no longer required. This is done with the following code:

QItemSelectionModel *m = view->selectionModel();
view->setModel(new model);
delete m;
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
const GLfloat * m
QSqlQueryModel * model
[16]
setIndexWidget(index, new QLineEdit)
[0]

If both the old model and the old selection model do not have parents, or if their parents are long-lived objects, it may be preferable to call their deleteLater() functions to explicitly delete them.

The view {does not} take ownership of the model unless it is the model's parent object because the model may be shared between many different views.

See also
selectionModel(), setSelectionModel()

Reimplemented from QAbstractItemView.

◆ setPreviewWidget()

void QColumnView::setPreviewWidget ( QWidget * widget)

◆ setResizeGripsVisible()

void QColumnView::setResizeGripsVisible ( bool visible)

◆ setRootIndex()

void QColumnView::setRootIndex ( const QModelIndex & index)
overridevirtual

Sets the root item to the item at the given index.

See also
rootIndex()

Reimplemented from QAbstractItemView.

◆ setSelection()

void QColumnView::setSelection ( const QRect & rect,
QItemSelectionModel::SelectionFlags flags )
overrideprotectedvirtual

Applies the selection flags to the items in or touched by the rectangle, rect.

When implementing your own itemview setSelection should call selectionModel()->select(selection, flags) where selection is either an empty QModelIndex or a QItemSelection that contains all items that are contained in rect.

See also
selectionCommand(), selectedIndexes()

Implements QAbstractItemView.

◆ setSelectionModel()

void QColumnView::setSelectionModel ( QItemSelectionModel * selectionModel)
overridevirtual

Sets the current selection model to the given selectionModel.

Note that, if you call setModel() after this function, the given selectionModel will be replaced by one created by the view.

Note
It is up to the application to delete the old selection model if it is no longer needed; i.e., if it is not being used by other views. This will happen automatically when its parent object is deleted. However, if it does not have a parent, or if the parent is a long-lived object, it may be preferable to call its deleteLater() function to explicitly delete it.
See also
selectionModel(), setModel(), clearSelection()

Reimplemented from QAbstractItemView.

◆ sizeHint()

QSize QColumnView::sizeHint ( ) const
override

◆ updatePreviewWidget

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

◆ verticalOffset()

int QColumnView::verticalOffset ( ) const
overrideprotectedvirtual

Returns the vertical offset of the view.

In the base class this is a pure virtual function.

See also
horizontalOffset()

Implements QAbstractItemView.

◆ visualRect()

QRect QColumnView::visualRect ( const QModelIndex & index) const
overridevirtual

Returns the rectangle on the viewport occupied by the item at index.

If your item is displayed in several areas then visualRect should return the primary area that contains index and not the complete area that index might encompasses, touch or cause drawing.

In the base class this is a pure virtual function.

See also
indexAt(), visualRegionForSelection()

Implements QAbstractItemView.

◆ visualRegionForSelection()

QRegion QColumnView::visualRegionForSelection ( const QItemSelection & selection) const
overrideprotectedvirtual

Returns the region from the viewport of the items in the given selection.

In the base class this is a pure virtual function.

See also
visualRect(), selectedIndexes()

Implements QAbstractItemView.

Property Documentation

◆ resizeGripsVisible

bool QColumnView::resizeGripsVisible
readwrite

Definition at line 19 of file qcolumnview.h.


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