Qt:Документация 4.3.2/qabstractitemview
Материал из Wiki.crossplatform.ru
Внимание: Актуальная версия перевода документации находится здесь |
__NOTOC__
Главная · Все классы · Основные классы · Классы по группам · Модули · Функции |
[править] QAbstractItemView Class Reference
[модуль QtGui ]
QAbstractItemView реализует базовый общий функционал графических элементов отображающих данные из моделей. Подробней...
#include <QAbstractItemView>
Наследует QAbstractScrollArea.
Наследуется QColumnView, QHeaderView, QListView, QTableView и QTreeView.
[править] Открытые типы
- enum DragDropMode { NoDragDrop, DragOnly, DropOnly, DragDrop, InternalMove }
- enum EditTrigger { NoEditTriggers, CurrentChanged, DoubleClicked, SelectedClicked, ..., AllEditTriggers }
- flags EditTriggers
- enum ScrollHint { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter }
- enum ScrollMode { ScrollPerItem, ScrollPerPixel }
- enum SelectionBehavior { SelectItems, SelectRows, SelectColumns }
- enum SelectionMode { SingleSelection, ContiguousSelection, ExtendedSelection, MultiSelection, NoSelection }
[править] Свойства
|
|
- 2 свойства унаследованных от QAbstractScrollArea
- 6 свойства унаследованных от QFrame
- 56 свойства унаследованных от QWidget
- 1 свойство унаследованное от QObject
[править] Открытые функции
- QAbstractItemView ( QWidget * parent = 0 )
- ~QAbstractItemView ()
- bool alternatingRowColors () const
- void closePersistentEditor ( const QModelIndex & index )
- QModelIndex currentIndex () const
- DragDropMode dragDropMode () const
- bool dragDropOverwriteMode () const
- bool dragEnabled () const
- EditTriggers editTriggers () const
- bool hasAutoScroll () const
- ScrollMode horizontalScrollMode () const
- QSize iconSize () const
- virtual QModelIndex indexAt ( const QPoint & point ) const = 0
- QWidget * indexWidget ( const QModelIndex & index ) const
- QAbstractItemDelegate * itemDelegate () const
- QAbstractItemDelegate * itemDelegate ( const QModelIndex & index ) const
- QAbstractItemDelegate * itemDelegateForColumn ( int column ) const
- QAbstractItemDelegate * itemDelegateForRow ( int row ) const
- virtual void keyboardSearch ( const QString & search )
- QAbstractItemModel * model () const
- void openPersistentEditor ( const QModelIndex & index )
- QModelIndex rootIndex () const
- virtual void scrollTo ( const QModelIndex & index, ScrollHint hint = EnsureVisible ) = 0
- QAbstractItemView::SelectionBehavior selectionBehavior () const
- QAbstractItemView::SelectionMode selectionMode () const
- QItemSelectionModel * selectionModel () const
- void setAlternatingRowColors ( bool enable )
- void setAutoScroll ( bool enable )
- void setDragDropMode ( DragDropMode behavior )
- void setDragDropOverwriteMode ( bool overwrite )
- void setDragEnabled ( bool enable )
- void setDropIndicatorShown ( bool enable )
- void setEditTriggers ( EditTriggers triggers )
- void setHorizontalScrollMode ( ScrollMode mode )
- void setIconSize ( const QSize & size )
- void setIndexWidget ( const QModelIndex & index, QWidget * widget )
- void setItemDelegate ( QAbstractItemDelegate * delegate )
- void setItemDelegateForColumn ( int column, QAbstractItemDelegate * delegate )
- void setItemDelegateForRow ( int row, QAbstractItemDelegate * delegate )
- virtual void setModel ( QAbstractItemModel * model )
- void setSelectionBehavior ( QAbstractItemView::SelectionBehavior behavior )
- void setSelectionMode ( QAbstractItemView::SelectionMode mode )
- virtual void setSelectionModel ( QItemSelectionModel * selectionModel )
- void setTabKeyNavigation ( bool enable )
- void setTextElideMode ( Qt::TextElideMode mode )
- void setVerticalScrollMode ( ScrollMode mode )
- bool showDropIndicator () const
- virtual int sizeHintForColumn ( int column ) const
- QSize sizeHintForIndex ( const QModelIndex & index ) const
- virtual int sizeHintForRow ( int row ) const
- bool tabKeyNavigation () const
- Qt::TextElideMode textElideMode () const
- ScrollMode verticalScrollMode () const
- virtual QRect visualRect ( const QModelIndex & index ) const = 0
- 15 открытых функций унаследованных от QAbstractScrollArea
- 13 открытых функций унаследованных от QFrame
- 201 открытых функций унаследованных от QWidget
- 29 открытых функций унаследованных от QObject
- 12 открытых функций унаследованных от QPaintDevice
[править] Открытые слоты
- void clearSelection ()
- void edit ( const QModelIndex & index )
- virtual void reset ()
- void scrollToBottom ()
- void scrollToTop ()
- virtual void selectAll ()
- void setCurrentIndex ( const QModelIndex & index )
- virtual void setRootIndex ( const QModelIndex & index )
- void update ( const QModelIndex & index )
[править] Сигналы
- void activated ( const QModelIndex & index )
- void clicked ( const QModelIndex & index )
- void doubleClicked ( const QModelIndex & index )
- void entered ( const QModelIndex & index )
- void pressed ( const QModelIndex & index )
- void viewportEntered ()
[править] Protected Types
- enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight, ..., MovePrevious }
- enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport }
- enum State { NoState, DraggingState, DragSelectingState, EditingState, ..., AnimatingState }
[править] Защищенные функции
- QPoint dirtyRegionOffset () const
- virtual void dragEnterEvent ( QDragEnterEvent * event )
- virtual void dragLeaveEvent ( QDragLeaveEvent * event )
- virtual void dragMoveEvent ( QDragMoveEvent * event )
- virtual void dropEvent ( QDropEvent * event )
- DropIndicatorPosition dropIndicatorPosition () const
- virtual bool edit ( const QModelIndex & index, EditTrigger trigger, QEvent * event )
- void executeDelayedItemsLayout ()
- virtual void focusInEvent ( QFocusEvent * event )
- virtual void focusOutEvent ( QFocusEvent * event )
- virtual int horizontalOffset () const = 0
- virtual bool isIndexHidden ( const QModelIndex & index ) const = 0
- virtual void keyPressEvent ( QKeyEvent * event )
- virtual void mouseDoubleClickEvent ( QMouseEvent * event )
- virtual void mouseMoveEvent ( QMouseEvent * event )
- virtual void mousePressEvent ( QMouseEvent * event )
- virtual void mouseReleaseEvent ( QMouseEvent * event )
- virtual QModelIndex moveCursor ( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) = 0
- virtual void resizeEvent ( QResizeEvent * event )
- void scheduleDelayedItemsLayout ()
- void scrollDirtyRegion ( int dx, int dy )
- virtual QModelIndexList selectedIndexes () const
- virtual QItemSelectionModel::SelectionFlags selectionCommand ( const QModelIndex & index, const QEvent * event = 0 ) const
- void setDirtyRegion ( const QRegion & region )
- virtual void setSelection ( const QRect & rect, QItemSelectionModel::SelectionFlags flags ) = 0
- void setState ( State state )
- virtual void startDrag ( Qt::DropActions supportedActions )
- State state () const
- virtual void timerEvent ( QTimerEvent * event )
- virtual int verticalOffset () const = 0
- virtual QStyleOptionViewItem viewOptions () const
- virtual bool viewportEvent ( QEvent * event )
- virtual QRegion visualRegionForSelection ( const QItemSelection & selection ) const = 0
- 16 защищенных функций унаследованных от QAbstractScrollArea
- 38 защищенных функций унаследованных от QWidget
- 7 защищенных функций унаследованных от QObject
- 1 защищенная функция унаследованна от QPaintDevice
[править] Защищенные слоты
- virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )
- virtual void commitData ( QWidget * editor )
- virtual void currentChanged ( const QModelIndex & current, const QModelIndex & previous )
- virtual void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight )
- virtual void editorDestroyed ( QObject * editor )
- virtual void rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end )
- virtual void rowsInserted ( const QModelIndex & parent, int start, int end )
- virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )
- 1 защищенный слот унаследованный от QAbstractScrollArea
- 1 защищенный слот унаследованный от QWidget
[править] Дополнительные унаследованные члены
- 4 статических открытых члена унаследованных от QWidget
- 5 статических открытых члена унаследованных от QObject
[править] Подробное описание
Класс QAbstractItemView реализует базовый общий функционал графических элементов отображающих данные из моделей.
QAbstractItemView является базовым классом для всех стандартных графических элементов отображающих данные из объектов класса QAbstractItemModel. QAbstractItemView - это абстрактный класс, и создавать его экземпляры непосредственно нельзя. Он предоставляет стандартный интерфейс для взаимодействия между моделями с помощью механизма сигналов и слотов для таких задач как синхронизация с изменениями в моделях. Данный класс обеспечивает простую поддержку работы с клавиатурой и мышью, прокрутки, редактирования записей и их выделения.
Класс QAbstractItemView - это один из классов модель-представление (Model-View) и входит в состав инфраструктуры модель-представление Qt.
Классы графических элементов, производные QAbstractItemView, должны реализовывать лишь функционал связанный с выводом данных на экран: рисование отдельных записей, предоставление геометрических данных для отдельных записей, поиск записей и т.д.
QAbstractItemView содержит общие слоты edit() и setCurrentIndex(). Также доступно несколько защищённых слотов, вкл.чая dataChanged(), rowsInserted(), rowsAboutToBeRemoved(), selectionChanged() и currentChanged().
Корневую запись (запись, таблицу которой элемент показывает) можно получить с помощью rootIndex(), а текущую - с помощью currentIndex(). Сделать запись видимой, выполнив прокрутку если это необходимо, можно с помощью scrollTo().
Функции QAbstractItemView, связанные с прокручиванием: setHorizontalScrollMode() и setVerticalScrollMode(). Для задания диапазона полос прокрутки можно, например, реализовать функцию resizeEvent() в производном классе:
void MyView::resizeEvent(QResizeEvent *event) { horizontalScrollBar()->setRange(0, realWidth - width()); ... }
Диапазон не обновляется до первого отображения виджета (событие show).
Функци, связанные с выделением записей: setSelectionMode() и setSelectionBehavior(). По умолчанию используется стандартная модель для работы с выделенными записями, но используемую модель можно поменять вызовом setSelectionModel(), передав ему при этом экземпляр класса QItemSelectionModel или производного от него.
Для того чтобы полностью контролировать отображение и редактирование отдельных записей передайте экземпляру настоящего класса свой делегат с п. setItemDelegate().
QAbstractItemView предоставляет множество защищённых функций. Некоторые из них связаны с редактированием записей, например, edit() и commitData(), другие - для обработки событий клавиатуры и мыши.
См. также Классы представлений, Парадигма »модель-представление», QAbstractItemModel и Пример Chart.
[править] Описание типов членов
[править] enum QAbstractItemView::CursorAction
This enum describes the different ways to navigate between items,
Constant | Value | Description |
---|---|---|
QAbstractItemView::MoveUp | 0 | Move to the item above the current item. |
QAbstractItemView::MoveDown | 1 | Move to the item below the current item. |
QAbstractItemView::MoveLeft | 2 | Move to the item left of the current item. |
QAbstractItemView::MoveRight | 3 | Move to the item right of the current item. |
QAbstractItemView::MoveHome | 4 | Move to the top-left corner item. |
QAbstractItemView::MoveEnd | 5 | Move to the bottom-right corner item. |
QAbstractItemView::MovePageUp | 6 | Move one page up above the current item. |
QAbstractItemView::MovePageDown | 7 | Move one page down below the current item. |
QAbstractItemView::MoveNext | 8 | Move to the item after the current item. |
QAbstractItemView::MovePrevious | 9 | Move to the item before the current item. |
See also moveCursor().
[править] 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 (NoDragDrop).
Constant | Value | Description |
---|---|---|
QAbstractItemView::NoDragDrop | 0 | Does not support dragging or dropping. |
QAbstractItemView::DragOnly | 1 | The view supports dragging of its own items |
QAbstractItemView::DropOnly | 2 | The view accepts drops |
QAbstractItemView::DragDrop | 3 | The view supports both dragging and dropping |
QAbstractItemView::InternalMove | 4 | only accepts move operations only from itself. |
Note that the model used needs to provide support for drag and drop operations.
This enum was introduced in Qt 4.2.
See also setDragDropMode() and Using Drag and Drop with Item Views.
[править] enum QAbstractItemView::DropIndicatorPosition
This enum indicates the position of the drop indicator in relation to the index at the current mouse position:
Constant | Value | Description |
---|---|---|
QAbstractItemView::OnItem | 0 | The item will be dropped on the index. |
QAbstractItemView::AboveItem | 1 | The item will be dropped above the index. |
QAbstractItemView::BelowItem | 2 | The item will be dropped below the index. |
QAbstractItemView::OnViewport | 3 | The item will be dropped onto a region of the viewport with no items. The way each view handles items dropped onto the viewport depends on the behavior of the underlying model in use. |
[править] enum QAbstractItemView::EditTrigger
flags QAbstractItemView::EditTriggers
This enum describes actions which will initiate item editing.
Constant | Value | Description |
---|---|---|
QAbstractItemView::NoEditTriggers | 0 | No editing possible. |
QAbstractItemView::CurrentChanged | 1 | Editing start whenever current item changes. |
QAbstractItemView::DoubleClicked | 2 | Editing starts when an item is double clicked. |
QAbstractItemView::SelectedClicked | 4 | Editing starts when clicking on an already selected item. |
QAbstractItemView::EditKeyPressed | 8 | Editing starts when the platform edit key has been pressed over an item. |
QAbstractItemView::AnyKeyPressed | 16 | Editing starts when any key is pressed over an item. |
QAbstractItemView::AllEditTriggers | 31 | Editing starts for all above actions. |
The EditTriggers type is a typedef for QFlags<EditTrigger>. It stores an OR combination of EditTrigger values.
[править] enum QAbstractItemView::ScrollHint
Constant | Value | Description |
---|---|---|
QAbstractItemView::EnsureVisible | 0 | Scroll to ensure that the item is visible. |
QAbstractItemView::PositionAtTop | 1 | Scroll to position the item at the top of the viewport. |
QAbstractItemView::PositionAtBottom | 2 | Scroll to position the item at the bottom of the viewport. |
QAbstractItemView::PositionAtCenter | 3 | Scroll to position the item at the center of the viewport. |
[править] enum QAbstractItemView::ScrollMode
Constant | Value | Description |
---|---|---|
QAbstractItemView::ScrollPerItem | 0 | The view will scroll the contents one item at a time. |
QAbstractItemView::ScrollPerPixel | 1 | The view will scroll the contents one pixel at a time. |
This enum was introduced in Qt 4.2.
[править] enum QAbstractItemView::SelectionBehavior
Constant | Value | Description |
---|---|---|
QAbstractItemView::SelectItems | 0 | Selecting single items. |
QAbstractItemView::SelectRows | 1 | Selecting only rows. |
QAbstractItemView::SelectColumns | 2 | Selecting only columns. |
[править] enum QAbstractItemView::SelectionMode
This enum indicates how the view responds to user selections:
Constant | Value | Description |
---|---|---|
QAbstractItemView::SingleSelection | 1 | When the user selects an item, any already-selected item becomes unselected, and the user cannot unselect the selected item. |
QAbstractItemView::ContiguousSelection | 4 | When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. |
QAbstractItemView::ExtendedSelection | 3 | When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. Multiple items can be selected by dragging the mouse over them. |
QAbstractItemView::MultiSelection | 2 | When the user selects an item in the usual way, the selection status of that item is toggled and the other items are left alone. Multiple items can be toggled by dragging the mouse over them. |
QAbstractItemView::NoSelection | 0 | Items cannot be selected. |
The most commonly used modes are SingleSelection and ExtendedSelection.
[править] enum QAbstractItemView::State
Describes the different states the view can be in. This is usually only interesting when reimplementing your own view.
Constant | Value | Description |
---|---|---|
QAbstractItemView::NoState | 0 | The is the default state. |
QAbstractItemView::DraggingState | 1 | The user is dragging items. |
QAbstractItemView::DragSelectingState | 2 | The user is selecting items. |
QAbstractItemView::EditingState | 3 | The user is editing an item in a widget editor. |
QAbstractItemView::ExpandingState | 4 | The user is opening a branch of items. |
QAbstractItemView::CollapsingState | 5 | The user is closing a branch of items. |
QAbstractItemView::AnimatingState | 6 | The item view is performing an animation. |
[править] Описание свойств
[править] alternatingRowColors : bool
This property holds whether to draw the background using alternating colors.
If this property is true, the item background will be drawn using QPalette::Base and QPalette::AlternateBase; otherwise the background will be drawn using the QPalette::Base color.
By default, this property is false.
Функции доступа:
- bool alternatingRowColors () const
- void setAlternatingRowColors ( bool enable )
[править] autoScroll : bool
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 this property to false.
Функции доступа:
- bool hasAutoScroll () const
- void setAutoScroll ( bool enable )
[править] dragDropMode : DragDropMode
This property holds the drag and drop event the view will act upon.
This property was introduced in Qt 4.2.
Функции доступа:
- DragDropMode dragDropMode () const
- void setDragDropMode ( DragDropMode behavior )
See also showDropIndicator and dragDropOverwriteMode.
[править] dragDropOverwriteMode : bool
This property holds the view's drag and drop behavior.
If its value is true, the selected data will overwrite the existing item data when dropped, while moving the data will clear the item. If its value is 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 false, as in the QListView and QTreeView subclasses. In the QTableView subclass, on the other hand, the property has been set to true.
This property was introduced in Qt 4.2.
Функции доступа:
- bool dragDropOverwriteMode () const
- void setDragDropOverwriteMode ( bool overwrite )
See also dragDropMode.
[править] dragEnabled : bool
This property holds whether the view supports dragging of its own items.
Функции доступа:
- bool dragEnabled () const
- void setDragEnabled ( bool enable )
See also showDropIndicator, DragDropMode, dragDropOverwriteMode, and acceptDrops.
[править] editTriggers : EditTriggers
This property holds which actions will initiate item editing.
This property is a selection of flags defined by 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.
Функции доступа:
- EditTriggers editTriggers () const
- void setEditTriggers ( EditTriggers triggers )
[править] horizontalScrollMode : ScrollMode
This property holds 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.
This property was introduced in Qt 4.2.
Функции доступа:
- ScrollMode horizontalScrollMode () const
- void setHorizontalScrollMode ( ScrollMode mode )
[править] iconSize : QSize
This property holds the size of items.
Setting this property when the view is visible will cause the items to be laid out again.
Функции доступа:
- QSize iconSize () const
- void setIconSize ( const QSize & size )
[править] selectionBehavior : SelectionBehavior
This property holds which selection behavior the view uses.
This property holds whether selections are done in terms of single items, rows or columns.
Функции доступа:
- QAbstractItemView::SelectionBehavior selectionBehavior () const
- void setSelectionBehavior ( QAbstractItemView::SelectionBehavior behavior )
See also SelectionMode and SelectionBehavior.
[править] selectionMode : SelectionMode
This property holds 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.
Функции доступа:
- QAbstractItemView::SelectionMode selectionMode () const
- void setSelectionMode ( QAbstractItemView::SelectionMode mode )
See also SelectionMode and SelectionBehavior.
[править] showDropIndicator : bool
This property holds whether the drop indicator is shown when dragging items and dropping.
Функции доступа:
- bool showDropIndicator () const
- void setDropIndicatorShown ( bool enable )
See also dragEnabled, DragDropMode, dragDropOverwriteMode, and acceptDrops.
[править] tabKeyNavigation : bool
This property holds whether item navigation with tab and backtab is enabled.
Функции доступа:
- bool tabKeyNavigation () const
- void setTabKeyNavigation ( bool enable )
[править] textElideMode : Qt::TextElideMode
This property holds the the position of the "..." in elided text.
Функции доступа:
- Qt::TextElideMode textElideMode () const
- void setTextElideMode ( Qt::TextElideMode mode )
[править] verticalScrollMode : ScrollMode
This property holds 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.
This property was introduced in Qt 4.2.
Функции доступа:
- ScrollMode verticalScrollMode () const
- void setVerticalScrollMode ( ScrollMode mode )
[править] Описание функций-членов
[править] QAbstractItemView::QAbstractItemView ( QWidget * parent = 0 )
Constructs an abstract item view with the given parent.
[править] QAbstractItemView::~QAbstractItemView ()
Destroys the view.
[править] void QAbstractItemView::activated ( const QModelIndex & index ) [signal]
This signal is emitted when the item specified by index is activated by the user. How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.
See also clicked(), doubleClicked(), entered(), and pressed().
[править] void QAbstractItemView::clearSelection () [slot]
Clears all selected items. The current index will not be changed.
See also setSelection() and selectAll().
[править] void QAbstractItemView::clicked ( const QModelIndex & index ) [signal]
This signal is emitted when a mouse button is clicked. The item the mouse was clicked on is specified by index. The signal is only emitted when the index is valid.
See also activated(), doubleClicked(), entered(), and pressed().
[править] void QAbstractItemView::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint ) [virtual protected slot]
Closes the given editor, and releases it. The hint is used to specify how the view should respond to the end of the editing operation. For example, the hint may indicate that the next item in the view should be opened for editing.
See also edit() and commitData().
[править] void QAbstractItemView::closePersistentEditor ( const QModelIndex & index )
Closes the persistent editor for the item at the given index.
See also openPersistentEditor().
[править] void QAbstractItemView::commitData ( QWidget * editor ) [virtual protected slot]
Commit the data in the editor to the model.
See also closeEditor().
[править] void QAbstractItemView::currentChanged ( const QModelIndex & current, const QModelIndex & previous ) [virtual protected slot]
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.
[править] QModelIndex QAbstractItemView::currentIndex () const
Returns the model index of the current item.
See also setCurrentIndex().
[править] void QAbstractItemView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) [virtual protected slot]
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.
[править] QPoint QAbstractItemView::dirtyRegionOffset () const [protected]
Returns the offset of the dirty regions in the view.
If you use scrollDirtyRegion() and implement a paintEvent() in a subclass of QAbstractItemView, you should translate the area given by the paint event with the offset returned from this function.
See also scrollDirtyRegion() and setDirtyRegion().
[править] void QAbstractItemView::doubleClicked ( const QModelIndex & index ) [signal]
This signal is emitted when a mouse button is double-clicked. The item the mouse was double-clicked on is specified by index. The signal is only emitted when the index is valid.
See also clicked() and activated().
[править] void QAbstractItemView::dragEnterEvent ( QDragEnterEvent * event ) [virtual protected]
This function is called with the given event when a drag and drop operation enters the widget. If the drag is over a valid dropping place (e.g. over an item that accepts drops), the event is accepted; otherwise it is ignored.
Reimplemented from QWidget.
See also dropEvent() and startDrag().
[править] void QAbstractItemView::dragLeaveEvent ( QDragLeaveEvent * event ) [virtual protected]
This function is called when the item being dragged leaves the view. The event describes the state of the drag and drop operation.
Reimplemented from QWidget.
[править] void QAbstractItemView::dragMoveEvent ( QDragMoveEvent * event ) [virtual protected]
This function is called continuously with the given event during a drag and drop operation over the widget. It can cause the view to scroll if, for example, the user drags a selection to view's right or bottom edge. In this case, the event will be accepted; otherwise it will be ignored.
Reimplemented from QWidget.
See also dropEvent() and startDrag().
[править] void QAbstractItemView::dropEvent ( QDropEvent * event ) [virtual protected]
This function is called with the given event when a drop event occurs over the widget. If the model accepts the even position the drop event is accepted; otherwise it is ignored.
Reimplemented from QWidget.
See also startDrag().
[править] DropIndicatorPosition QAbstractItemView::dropIndicatorPosition () const [protected]
Returns the position of the drop indicator in relation to the closest item.
This function was introduced in Qt 4.1.
[править] void QAbstractItemView::edit ( const QModelIndex & index ) [slot]
Starts editing the item corresponding to the given 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.
See also QModelIndex::flags().
[править] bool QAbstractItemView::edit ( const QModelIndex & index, EditTrigger trigger, QEvent * event ) [virtual protected]
This is an overloaded member function, provided for convenience.
Starts editing the item at index, creating an editor if necessary, and returns true if the view's State is now EditingState; otherwise returns false.
The action that caused the editing process is described by trigger, and the associated event is specified by event.
Editing can be forced by specifying the trigger to be QAbstractItemView::AllEditTriggers.
See also closeEditor().
[править] void QAbstractItemView::editorDestroyed ( QObject * editor ) [virtual protected slot]
This function is called when the given editor has been destroyed.
See also closeEditor().
[править] void QAbstractItemView::entered ( const QModelIndex & index ) [signal]
This signal is emitted when the mouse cursor enters the item specified by index. Mouse tracking needs to be enabled for this feature to work.
See also viewportEntered(), activated(), clicked(), doubleClicked(), and pressed().
[править] void QAbstractItemView::executeDelayedItemsLayout () [protected]
Executes the scheduled layouts without waiting for the event processing to begin.
See also scheduleDelayedItemsLayout().
[править] void QAbstractItemView::focusInEvent ( QFocusEvent * event ) [virtual protected]
This function is called with the given event when the widget obtains the focus. By default, the event is ignored.
Reimplemented from QWidget.
See also setFocus() and focusOutEvent().
[править] void QAbstractItemView::focusOutEvent ( QFocusEvent * event ) [virtual protected]
This function is called with the given event when the widget looses the focus. By default, the event is ignored.
Reimplemented from QWidget.
See also clearFocus() and focusInEvent().
[править] int QAbstractItemView::horizontalOffset () const [pure virtual protected]
Returns the horizontal offset of the view.
In the base class this is a pure virtual function.
See also verticalOffset().
[править] QModelIndex QAbstractItemView::indexAt ( const QPoint & point ) const [pure virtual]
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().
[править] QWidget * QAbstractItemView::indexWidget ( const QModelIndex & index ) const
Returns the widget for the item at the given index.
This function was introduced in Qt 4.1.
See also setIndexWidget().
[править] bool QAbstractItemView::isIndexHidden ( const QModelIndex & index ) const [pure virtual protected]
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.
[править] QAbstractItemDelegate * QAbstractItemView::itemDelegate () const
Returns the item delegate used by this view and model. This is either one set with setItemDelegate(), or the default one.
See also setItemDelegate().
[править] QAbstractItemDelegate * QAbstractItemView::itemDelegate ( const QModelIndex & index ) const
This is an overloaded member function, provided for convenience.
Returns the item delegate used by this view and model for the given index.
[править] QAbstractItemDelegate * QAbstractItemView::itemDelegateForColumn ( int column ) const
Returns the item delegate used by this view and model for the given column. You can call itemDelegate() to get a pointer to the current delegate for a given index.
This function was introduced in Qt 4.2.
See also setItemDelegateForColumn(), itemDelegateForRow(), and itemDelegate().
[править] QAbstractItemDelegate * QAbstractItemView::itemDelegateForRow ( int row ) const
Returns the item delegate used by this view and model for the given row, or 0 if no delegate has been assigned. You can call itemDelegate() to get a pointer to the current delegate for a given index.
This function was introduced in Qt 4.2.
See also setItemDelegateForRow(), itemDelegateForColumn(), and setItemDelegate().
[править] void QAbstractItemView::keyPressEvent ( QKeyEvent * event ) [virtual protected]
This function is called with the given event when a key event is sent to the widget. The default implementation handles basic cursor movement, e.g. Up, Down, Left, Right, Home, PageUp, and PageDown; the activated() signal is emitted if the current index is valid and the activation key is pressed (e.g. Enter or Return, depending on the platform). This function is where editing is initiated by key press, e.g. if F2 is pressed.
Reimplemented from QWidget.
See also edit(), moveCursor(), keyboardSearch(), and tabKeyNavigation.
[править] void QAbstractItemView::keyboardSearch ( const QString & search ) [virtual]
Moves to and selects the item best matching the string search. If no item is found nothing happens.
In the default implementation, the search is reset if search is empty, or the time interval since the last search has exceeded QApplication::keyboardInputInterval().
[править] QAbstractItemModel * QAbstractItemView::model () const
Returns the model that this view is presenting.
See also setModel().
[править] void QAbstractItemView::mouseDoubleClickEvent ( QMouseEvent * event ) [virtual protected]
This function is called with the given event when a mouse button is double clicked inside the widget. If the double-click is on a valid item it emits the doubleClicked() signal and calls edit() on the item.
Reimplemented from QWidget.
[править] void QAbstractItemView::mouseMoveEvent ( QMouseEvent * event ) [virtual protected]
This function is called with the given event when a mouse move event is sent to the widget. 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.
[править] void QAbstractItemView::mousePressEvent ( QMouseEvent * event ) [virtual protected]
This function is called with the given event when a mouse button is pressed while the cursor is inside the widget. If a valid item is pressed on it is made into the current item. This function emits the pressed() signal.
Reimplemented from QWidget.
[править] void QAbstractItemView::mouseReleaseEvent ( QMouseEvent * event ) [virtual protected]
This function is called with the given event when a mouse button is released, after a mouse press event on the widget. If a user presses the mouse inside your widget and then drags the mouse to another location before releasing the mouse button, your widget receives the release event. The function will emit the clicked() signal if an item was being pressed.
Reimplemented from QWidget.
[править] QModelIndex QAbstractItemView::moveCursor ( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) [pure virtual protected]
Moves the cursor in the view according to the given cursorAction and keyboard modifiers specified by modifiers.
In the base class this is a pure virtual function.
[править] void QAbstractItemView::openPersistentEditor ( const QModelIndex & index )
Opens a persistent editor on the item at the given index. If no editor exists, the delegate will create a new editor.
See also closePersistentEditor().
[править] void QAbstractItemView::pressed ( const QModelIndex & index ) [signal]
This signal is emitted when a mouse button is pressed. The item the mouse was pressed on is specified by index. The signal is only emitted when the index is valid.
See also activated(), clicked(), doubleClicked(), and entered().
[править] void QAbstractItemView::reset () [virtual slot]
Reset the internal state of the view.
[править] void QAbstractItemView::resizeEvent ( QResizeEvent * event ) [virtual protected]
This function is called with the given event when a resize event is sent to the widget.
Reimplemented from QWidget.
See also QWidget::resizeEvent().
[править] QModelIndex QAbstractItemView::rootIndex () const
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.
See also setRootIndex().
[править] void QAbstractItemView::rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end ) [virtual protected slot]
This slot is called when rows are about to be removed. The deleted rows are those under the given parent from start to end inclusive.
See also rowsInserted().
[править] void QAbstractItemView::rowsInserted ( const QModelIndex & parent, int start, int end ) [virtual protected slot]
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().
[править] void QAbstractItemView::scheduleDelayedItemsLayout () [protected]
Schedules a layout of the items in the view to be executed when the event processing starts.
Even if scheduleDelayedItemsLayout() is called multiple times before events are processed, the view will only do the layout once.
See also executeDelayedItemsLayout().
[править] void QAbstractItemView::scrollDirtyRegion ( int dx, int dy ) [protected]
Prepares the view for scrolling by (dx,dy) pixels by moving the dirty regions in the opposite direction. You only need to call this function if you are implementing a scrolling viewport in your view subclass.
If you implement scrollContentsBy() in a subclass of QAbstractItemView, call this function before you call QWidget::scroll() on the viewport. Alternatively, just call update().
See also scrollContentsBy(), dirtyRegionOffset(), and setDirtyRegion().
[править] void QAbstractItemView::scrollTo ( const QModelIndex & index, ScrollHint hint = EnsureVisible ) [pure virtual]
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.
[править] void QAbstractItemView::scrollToBottom () [slot]
Scrolls the view to the bottom.
This function was introduced in Qt 4.1.
See also scrollTo() and scrollToTop().
[править] void QAbstractItemView::scrollToTop () [slot]
Scrolls the view to the top.
This function was introduced in Qt 4.1.
See also scrollTo() and scrollToBottom().
[править] void QAbstractItemView::selectAll () [virtual slot]
Selects all non-hidden items.
See also setSelection(), selectedIndexes(), and clearSelection().
[править] QModelIndexList QAbstractItemView::selectedIndexes () const [virtual protected]
This convenience function returns a list of all selected and non-hidden item indexes in the view. The list contains no duplicates, and is not sorted.
The default implementation does nothing.
See also QItemSelectionModel::selectedIndexes().
[править] void QAbstractItemView::selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) [virtual protected slot]
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.
See also setSelection().
[править] QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand ( const QModelIndex & index, const QEvent * event = 0 ) const [virtual protected]
Returns the SelectionFlags to be used when updating a selection with to include the index specified. The event is a user input event, such as a mouse or keyboard event.
Reimplement this function to define your own selection behavior.
See also setSelection().
[править] QItemSelectionModel * QAbstractItemView::selectionModel () const
Returns the current selection model.
See also setSelectionModel() and selectedIndexes().
[править] void QAbstractItemView::setCurrentIndex ( const QModelIndex & index ) [slot]
Sets the current item to be the item at 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
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
See also currentIndex(), currentChanged(), and selectionMode.
[править] void QAbstractItemView::setDirtyRegion ( const QRegion & region ) [protected]
Marks the given region as dirty and schedules it to be updated. You only need to call this function if you are implementing your own view subclass.
This function was introduced in Qt 4.1.
See also scrollDirtyRegion() and dirtyRegionOffset().
[править] void QAbstractItemView::setIndexWidget ( const QModelIndex & index, QWidget * widget )
Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport.
If index is invalid (e.g., if you pass the root index), this function will do nothing.
Note that the given widget's autoFillBackground property must be set to true, otherwise the widget's background will be transparent, showing both the model data and the item at the given index.
This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass QItemDelegate instead.
This function was introduced in Qt 4.1.
See also indexWidget() and Delegate Classes.
[править] void QAbstractItemView::setItemDelegate ( QAbstractItemDelegate * delegate )
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.
Any existing delegate will be removed, but not deleted. QAbstractItemView does not take ownership of delegate.
Warning: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.
See also itemDelegate().
[править] void QAbstractItemView::setItemDelegateForColumn ( int column, QAbstractItemDelegate * delegate )
Sets the given item delegate used by this view and model for the given column. All items on column will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate()).
Any existing column delegate for column will be removed, but not deleted. QAbstractItemView does not take ownership of delegate.
Note: If a delegate has been assigned to both a row and a column, the row delegate will take presedence and manage the intersecting cell index.
Warning: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.
This function was introduced in Qt 4.2.
See also itemDelegateForColumn(), setItemDelegateForRow(), and itemDelegate().
[править] void QAbstractItemView::setItemDelegateForRow ( int row, QAbstractItemDelegate * delegate )
Sets the given item delegate used by this view and model for the given row. All items on row will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate()).
Any existing row delegate for row will be removed, but not deleted. QAbstractItemView does not take ownership of delegate.
Note: If a delegate has been assigned to both a row and a column, the row delegate (i.e., this delegate) will take presedence and manage the intersecting cell index.
Warning: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.
This function was introduced in Qt 4.2.
See also itemDelegateForRow(), setItemDelegateForColumn(), and itemDelegate().
[править] void QAbstractItemView::setModel ( QAbstractItemModel * model ) [virtual]
Sets the model for the view to present.
Note: This function will also create and set a new selection model, replacing any previously set with setSelectionModel(), but the old selection model will not be deleted.
See also model(), selectionModel(), and setSelectionModel().
[править] void QAbstractItemView::setRootIndex ( const QModelIndex & index ) [virtual slot]
Sets the root item to the item at the given index.
See also rootIndex().
[править] void QAbstractItemView::setSelection ( const QRect & rect, QItemSelectionModel::SelectionFlags flags ) [pure virtual protected]
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() and selectedIndexes().
[править] void QAbstractItemView::setSelectionModel ( QItemSelectionModel * selectionModel ) [virtual]
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 a one created by the view.
See also selectionModel(), setModel(), and clearSelection().
[править] void QAbstractItemView::setState ( State state ) [protected]
Sets the item view's state to the given state.
See also state().
[править] int QAbstractItemView::sizeHintForColumn ( int column ) const [virtual]
Returns the width size hint for the specified column or -1 if there is no model.
This function is used in views with a horizontal header to find the size hint for a header section based on the contents of the given column.
See also sizeHintForRow().
[править] QSize QAbstractItemView::sizeHintForIndex ( const QModelIndex & index ) const
Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
See also sizeHintForRow() and sizeHintForColumn().
[править] int QAbstractItemView::sizeHintForRow ( int row ) const [virtual]
Returns the height size hint for the specified row or -1 if there is no model.
The returned height is calculated using the size hints of the given row's items, i.e. the returned value is the maximum height among the items. Note that to control the height of a row, you must reimplement the QAbstractItemDelegate::sizeHint() function.
This function is used in views with a vertical header to find the size hint for a header section based on the contents of the given row.
See also sizeHintForColumn().
[править] void QAbstractItemView::startDrag ( Qt::DropActions supportedActions ) [virtual protected]
Starts a drag by calling drag->start() using the given supportedActions.
[править] State QAbstractItemView::state () const [protected]
Returns the item view's state.
See also setState().
[править] void QAbstractItemView::timerEvent ( QTimerEvent * event ) [virtual protected]
This function is called with the given event when a timer event is sent to the widget.
Reimplemented from QObject.
See also QObject::timerEvent().
[править] void QAbstractItemView::update ( const QModelIndex & index ) [slot]
Updates the area occupied by the given index.
This function was introduced in Qt 4.3.
[править] int QAbstractItemView::verticalOffset () const [pure virtual protected]
Returns the vertical offset of the view.
In the base class this is a pure virtual function.
See also horizontalOffset().
[править] QStyleOptionViewItem QAbstractItemView::viewOptions () const [virtual protected]
Returns a QStyleOptionViewItem structure populated with the view's palette, font, state, alignments etc.
[править] void QAbstractItemView::viewportEntered () [signal]
This signal is emitted when the mouse cursor enters the viewport. Mouse tracking needs to be enabled for this feature to work.
See also entered().
[править] bool QAbstractItemView::viewportEvent ( QEvent * event ) [virtual protected]
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. It passes all other events on to its base class viewportEvent() handler.
Reimplemented from QAbstractScrollArea.
[править] QRect QAbstractItemView::visualRect ( const QModelIndex & index ) const [pure virtual]
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() and visualRegionForSelection().
[править] QRegion QAbstractItemView::visualRegionForSelection ( const QItemSelection & selection ) const [pure virtual protected]
Возвращает часть области отображения, содержащую записи из набора selection.
В базовом классе эта виртуальная функция не реализована.
См. также visualRect() и selectedIndexes().
Copyright © 2007 Trolltech | Trademarks | Qt 4.3.2
|