Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QAbstractItemView class is the base class for every view that uses a QAbstractItemModel. More...
#include <QAbstractItemView>
Inherits QViewport.
Inherited by QHeaderView, QListView, QTableView, and QTreeView.
The QAbstractItemView class is the base class for every view that uses a QAbstractItemModel.
This class is a QViewport subclass that provides all the functionality common to all views, such as keyboard and mouse support for editing items, scrolling, and selection control; (but note that selections are handled separately by the QItemSelectionModel class).
The view classes that inherit QAbstractItemView only need to implement their own view-specific functionality, such as drawing items, returning the geometry of items, finding items, etc.
QAbstractItemView provides common slots such as edit() and setCurrentItem(), and common signals such as clicked(), doubleClicked(), returnPressed(), spacePressed(), and deletePressed(). Many protected slots are also provided, including dataChanged(), rowsInserted(), rowsRemoved(), columnsInserted(), columnsRemoved(), selectionChanged(), and currentChanged().
The root item is returned by root(), and the current item by currentItem(). To make sure that an item is visible use ensureItemVisible().
Some of QAbstractItemView's functions are concerned with scrolling, for example setHorizontalFactor() and setVerticalFactor(). Several other functions are concerned with selection control; for example setSelectionMode(), and setSelectionBehavior(). This class provides a default selection model to work with (selectionModel()), but this can be replaced by using setSelectionModel() with an instance of QItemSelectionModel.
For complete control over the display and editing of items you can specify a delegate with setItemDelegate().
QAbstractItemView provides a lot of protected functions. Some are concerned with editing, for example, beginEdit(), endEdit(), and currentEditor(), whilst others are keyboard and mouse event handlers.
See also Model/View Programming and QAbstractItemModel.
QAbstractItemView::MoveUp | |
QAbstractItemView::MoveDown | |
QAbstractItemView::MoveLeft | |
QAbstractItemView::MoveRight | |
QAbstractItemView::MoveHome | |
QAbstractItemView::MoveEnd | |
QAbstractItemView::MovePageUp | |
QAbstractItemView::MovePageDown |
QAbstractItemView::SelectItems | |
QAbstractItemView::SelectRows | |
QAbstractItemView::SelectColumns |
QAbstractItemView::SingleSelection | |
QAbstractItemView::MultiSelection | |
QAbstractItemView::ExtendedSelection |
QAbstractItemView::NoState | |
QAbstractItemView::Dragging | |
QAbstractItemView::Selecting | |
QAbstractItemView::Editing | |
QAbstractItemView::Opening | |
QAbstractItemView::Closing |
This property holds 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 the property to false.
Access functions:
This property holds which actions will initiate item editing.
This property is an OR'ed flag of QAbstractItemDelegate::BeginEditActions. The view will only initiate the editing of an item if the action performed is set in this property.
Access functions:
This property holds the interval threshold for doing keyboard searches.
Access functions:
Creates a new QAbstractItemView with parent parent.
Destroys the view.
This signal is emitted when the context menu is invoked. The menu is an empty menu; if you populate it with actions it will be popped up for the user. The current item when the contex menu event occurred is specified by index.
Starts editing the item at index, creating an editor if necessary, and returns true if the view's State is now Editing; otherwise returns false. The action that initiated the editing is specified by action, and the event that was behind this is specified by event.
See also endEdit() and QAbstractItemDelegate::releaseEditor().
Clears the selection.
This signal is emitted when a mouse button is clicked. The button is specified by button (see Qt::ButtonState), and the item the mouse was clicked on is specified by index (which may be invalid if the mouse was not clicked on an item).
Returns the width size hint for the specified column.
This function is called when context menu event e occurs. It emits the aboutToShowContextMenu() signal with a pointer to a QMenu object; if this QMenu object is populated with actions (e.g. in a slot you've connected to the aboutToShowContextMenu() signal), then the menu is shown.
Reimplemented from QWidget.
This slot is called when a new item becomes the current item. The previous current item is specified by the old index, and the new item by the current index.
If you want to know about changes to items see the dataChanged() signal.
Returns the editor if the view is in the Editing State; otherwise returns 0.
Returns the model index of the current item.
See also setCurrentItem().
This slot is called when items are changed in the model. The changed items are those from topLeft to bottomRight inclusive. If just one item is changed topLeft == bottomRight.
This signal is emitted when the Delete key is pressed. The item to be acted on by the key press is specified by index.
This signal is emitted when a mouse button is double-clicked. The button is specified by button (see Qt::ButtonState), and the item the mouse was double-clicked on is specified by index (which may be invalid if the mouse was not double-clicked on an item).
This function is called when drag enter event e occurs. If the drag is over a valid dropping place (e.g. over an item that accepts drops), the event is accepted.
Reimplemented from QWidget.
See also dropEvent() and startDrag().
This function is called when drag move event e occurs. It can cause the view to scroll, for example if the user drags a selection to view's right or bottom edge.
Reimplemented from QWidget.
See also dropEvent() and startDrag().
Returns a new drag object that contains the model indexes of all the model's selected items.
See also startDrag().
This function is called when drop event e occurs. If there's a valid item under the mouse pointer when the drop occurs, the drop is accepted.
Reimplemented from QWidget.
See also startDrag().
Calls beginEdit() for the item at index.
If accept is true the edit of the item at index is accepted and the model is updated with the editor's value. If accept is false, the edited value is ignored. In both cases, if there was an editor widget it is released.
See also beginEdit() and QAbstractItemDelegate::releaseEditor().
Scrolls the view if necessary to ensure that the item at index is visible.
In the base class this is a pure virtual function.
This function is used to handle tool tips, status tips, and What's This? mode, if the given event is a QEvent::ToolTip, a QEvent::WhatsThis, or a QEvent::StatusTip. It passes all other events on to its base class event() handler.
Reimplemented from QObject.
If the object is the current editor: if the event is an Esc key press the current edit is cancelled and ended, or if the event is an Enter or Return key press the current edit is accepted and ended. If editing is ended the event filter returns true to signify that it has handled the event; in all other cases it does nothing and returns false to signify that the event hasn't been handled.
Reimplemented from QObject.
See also endEdit().
This function is called when focus event e occurs and is a focus in event.
Reimplemented from QWidget.
This function is called when focus event e occurs and is a focus out event.
Reimplemented from QWidget.
Returns the horizontal scrollbar's stepping factor.
See also setHorizontalFactor() and verticalFactor().
Returns the horizontal offset of the view.
In the base class this is a pure virtual function.
Returns true if the item view allows the item at position index to be dragged; otherwise returns false.
Returns the model index of the item at point (x, y).
In the base class this is a pure virtual function.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the model index of the item at point p.
In the base class this is built on the other itemAt() function, which is pure virtual.
Returns the item delegate used by this view and model. This is either one set with setItemDelegate(), or the default one.
See also setItemDelegate().
Returns the size hint for the item with the specified index.
Returns the rectangle on the viewport occupied by the item at index.
In the base class this is a pure virtual function.
This function is called when a key event e occurs. It handles basic cursor movement, e.g. Up, Down, Left, Right, Home, PageUp, and PageDown, and emits the returnPressed(), spacePressed(), and deletePressed() signals is the associated key is pressed. This function is where editing is initiated by key press, e.g. if F2 is pressed.
Reimplemented from QWidget.
See also beginEdit().
Moves to and selects the item best matching the string search. If no item is found nothing happens.
Returns the model that this view is presenting.
This function is called when a mouse double-click event e occurs. If the double-click is on a valid item it emits the doubleClicked() signal and calls beginEdit() on the item.
Reimplemented from QWidget.
This function is called when a mouse move event e occurs. If a selection is in progress and new items are moved over the selection is extended; if a drag is in progress it is continued.
Reimplemented from QWidget.
This function is called when a mouse event e occurs. If a valid item is pressed on it is made into the current item. This function emits the pressed() signal.
Reimplemented from QWidget.
This function is called when a mouse release event e occurs. It will emit the clicked() signal if an item was being pressed and will send a context menu event if it is a right-mouse button release.
Reimplemented from QWidget.
See also contextMenuEvent().
Moves the cursor in the view in accordance with the given cursorAction and button state.
This signal is emitted when the cursor is positioned on the item specified by index. The button state is specified by button (see Qt::ButtonState).
This signal is emitted when a mouse button is pressed. The button is specified by button (see Qt::ButtonState), and the item the mouse was pressed on is specified by index (which may be invalid if the mouse was not pressed on an item).
This function is called when a resize event e occurs.
Reimplemented from QWidget.
This signal is emitted when Return (or Enter) is pressed. The item to be acted on by the key press is specified by index.
Returns the model index of the model's ``root'' item.
See also setRoot().
This signal is emitted when the model's root index changes. The previous index is specified by old, and the new root index is specified by root.
Returns the height size hint for the specified row.
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 does nothing.
See also rowsRemoved().
This slot is called when rows are removed. The deleted rows are those under the given parent from start to end inclusive. The base class implementation does nothing.
See also rowsInserted().
Returns the SelectionBehavior flags.
See also setSelectionBehavior() and SelectionMode.
This slot is called when the selection is changed. The previous selection (which may be empty), is specified by deselected, and the new selection by selected.
Returns the SelectionFlags to be used when updating selections. Reimplement this function to add your own selection behavior.
This function is called on user input events like mouse and keyboard events; the mouse button state is specified by state, the index of the relevant item by index, the even type by type, and the key (if a key was pressed) by key.
Returns the SelectionMode flags.
See also setSelectionMode() and SelectionBehavior.
Returns the current selection.
See also setSelectionModel() and clearSelections().
Returns the rectangle from the viewport of the items in the given selection.
Sets the current item to be the item at index.
See also currentItem().
Sets the horizontal scrollbar's stepping factor to factor.
See also horizontalFactor() and setVerticalFactor().
Sets the item delegate for this view and its model to delegate. This is useful if you want complete control over the editing and display of items.
See also itemDelegate().
Sets the model for the view to present.
Sets editor as the persisten editor for the item at the given index. If editor is 0 and no previous persistent editor has been set for the index, the editor will be created by the delegate.
Sets the ``root'' item to the item at index.
See also root().
Applies the selection flags to the items in or touched by the rectangle, rect.
See also selectionCommand().
Sets the SelectionBehavior flags to behavior.
See also selectionBehavior() and SelectionMode.
Sets the SelectionMode flags to mode.
See also selectionMode() and SelectionBehavior.
Sets the current selection to be selectionModel.
See also selectionModel() and clearSelections().
Sets the item view's state to state
See also state().
Sets the vertical scrollbar's stepping factor to factor.
See also verticalFactor() and setHorizontalFactor().
This signal is emitted when Space is pressed. The item to be acted on by the key press is specified by index.
internal
Starts a drag by calling drag() on a new dragObject().
Returns the item view's state.
See also setState().
internal
This function is called when a timer event e occurs.
Reimplemented from QObject.
Returns the vertical scrollbar's stepping factor.
See also setVerticalFactor() and horizontalFactor().
Returns the vertical offset of the view.
In the base class this is a pure virtual function.
Returns QStyleOptionViewItem structure populated with the view's palette and whether or not the view is in the Editing state.
Copyright © 2004 Trolltech. | Trademarks | Qt 4.0.0-tp1 |