|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QFrame
com.trolltech.qt.gui.QAbstractScrollArea
com.trolltech.qt.gui.QAbstractItemView
public abstract class QAbstractItemView
The QAbstractItemView
class provides the basic functionality for item view classes. QAbstractItemView
class is the base class for every standard view that uses a QAbstractItemModel
. QAbstractItemView
is an abstract class and cannot itself be instantiated. It provides a standard interface for interoperating with models through the signals and slots mechanism, enabling subclasses to be kept up-to-date with changes to their models. This class provides standard support for keyboard and mouse navigation, viewport scrolling, item editing, and selections.
The QAbstractItemView
class is one of the Model/View Classes and is part of Qt's model/view framework.
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 setCurrentIndex()
. Many protected slots are also provided, including dataChanged()
, rowsInserted()
, rowsAboutToBeRemoved()
, selectionChanged()
, and currentChanged()
.
The root item is returned by rootIndex()
, and the current item by currentIndex()
. To make sure that an item is visible use scrollTo()
.
Some of QAbstractItemView
's functions are concerned with scrolling, for example setHorizontalScrollMode()
and setVerticalScrollMode()
. To set the range of the scroll bars, you can, for example, reimplement the view's resizeEvent()
function:
The following code example is written in c++.
void MyView::resizeEvent(QResizeEvent *event) { horizontalScrollBar()->setRange(0, realWidth - width()); ... }Note that the range is not updated until the widget is shown.
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, edit()
, and commitData()
, whilst others are keyboard and mouse event handlers.
Note: If you inherit QAbstractItemView
and intend to update the contents of the viewport, you should use viewport->update()
instead of update()
as all painting operations take place on the viewport.
QAbstractItemModel
, and Chart Example.
Nested Class Summary | |
---|---|
static class |
QAbstractItemView.CursorAction
|
static class |
QAbstractItemView.DragDropMode
Describes the various drag and drop events the view can act upon. |
static class |
QAbstractItemView.DropIndicatorPosition
This enum indicates the position of the drop indicator in relation to the index at the current mouse position. |
static class |
QAbstractItemView.EditTrigger
This enum describes actions which will initiate item editing. |
static class |
QAbstractItemView.EditTriggers
This is a flags class for com.trolltech.qt.gui.QAbstractItemView.EditTrigger |
static class |
QAbstractItemView.ScrollHint
|
static class |
QAbstractItemView.ScrollMode
|
static class |
QAbstractItemView.SelectionBehavior
|
static class |
QAbstractItemView.SelectionMode
This enum describes the types of selection offered to the user for selecting dates in the calendar. |
static class |
QAbstractItemView.State
This enum describes the state of a window. |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame |
---|
QFrame.Shadow, QFrame.Shape, QFrame.StyleMask |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
activated
This signal is emitted when the item specified by index is activated by the user. |
QSignalEmitter.Signal1 |
clicked
This signal is emitted when a mouse button is clicked. |
QSignalEmitter.Signal1 |
doubleClicked
This signal is emitted when a mouse button is double-clicked. |
QSignalEmitter.Signal1 |
entered
This signal is emitted when the mouse cursor enters the item specified by index. |
QSignalEmitter.Signal1 |
pressed
This signal is emitted when a mouse button is pressed. |
QSignalEmitter.Signal0 |
viewportEntered
This signal is emitted when the mouse cursor enters the viewport. |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Constructor Summary | |
---|---|
QAbstractItemView()
Constructs an abstract item view with the given parent. |
|
QAbstractItemView(QWidget parent)
Constructs an abstract item view with the given parent. |
Method Summary | |
---|---|
boolean |
alternatingRowColors()
This property holds whether to draw the background using alternating colors. |
int |
autoScrollMargin()
This property holds the size of the area when auto scrolling is triggered. |
void |
clearSelection()
Deselects all selected items. |
protected void |
closeEditor(QWidget editor,
QAbstractItemDelegate.EndEditHint hint)
Closes the given editor, and releases it. |
void |
closePersistentEditor(QModelIndex index)
Closes the persistent editor for the item at the given index. |
protected void |
commitData(QWidget editor)
Commit the data in the editor to the model. |
protected void |
currentChanged(QModelIndex current,
QModelIndex previous)
This slot is called when a new item becomes the current item. |
QModelIndex |
currentIndex()
Returns the model index of the current item. |
protected void |
dataChanged(QModelIndex topLeft,
QModelIndex bottomRight)
This slot is called when items are changed in the model. |
protected QPoint |
dirtyRegionOffset()
Returns the offset of the dirty regions in the view. |
QAbstractItemView.DragDropMode |
dragDropMode()
This property holds the drag and drop event the view will act upon. |
boolean |
dragDropOverwriteMode()
This property holds the view's drag and drop behavior. |
boolean |
dragEnabled()
This property holds whether the view supports dragging of its own items. |
protected QAbstractItemView.DropIndicatorPosition |
dropIndicatorPosition()
Returns the position of the drop indicator in relation to the closest item. |
void |
edit(QModelIndex index)
Starts editing the item corresponding to the given index if it is editable. |
protected boolean |
edit(QModelIndex index,
QAbstractItemView.EditTrigger trigger,
QEvent event)
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. |
protected void |
editorDestroyed(QObject editor)
This function is called when the given editor has been destroyed. |
QAbstractItemView.EditTriggers |
editTriggers()
This property holds which actions will initiate item editing. |
protected void |
executeDelayedItemsLayout()
Executes the scheduled layouts without waiting for the event processing to begin. |
static QAbstractItemView |
fromNativePointer(QNativePointer nativePointer)
|
boolean |
hasAutoScroll()
This property holds whether autoscrolling in drag move events is enabled. |
protected abstract int |
horizontalOffset()
Returns the horizontal offset of the view. |
QAbstractItemView.ScrollMode |
horizontalScrollMode()
This property holds how the view scrolls its contents in the horizontal direction. |
QSize |
iconSize()
This property holds the size of items. |
abstract QModelIndex |
indexAt(QPoint point)
Returns the model index of the item at the viewport coordinates point. |
QWidget |
indexWidget(QModelIndex index)
Returns the widget for the item at the given index. |
protected abstract boolean |
isIndexHidden(QModelIndex index)
Returns true if the item referred to by the given index is hidden in the view, otherwise returns false. |
QAbstractItemDelegate |
itemDelegate()
Returns the item delegate used by this view and model. |
QAbstractItemDelegate |
itemDelegate(QModelIndex index)
Returns the item delegate used by this view and model for the given index. |
QAbstractItemDelegate |
itemDelegateForColumn(int column)
Returns the item delegate used by this view and model for the given column. |
QAbstractItemDelegate |
itemDelegateForRow(int row)
Returns the item delegate used by this view and model for the given row, or 0 if no delegate has been assigned. |
void |
keyboardSearch(java.lang.String search)
Moves to and selects the item best matching the string search. |
QAbstractItemModel |
model()
Returns the model that this view is presenting. |
protected abstract QModelIndex |
moveCursor(QAbstractItemView.CursorAction cursorAction,
Qt.KeyboardModifiers modifiers)
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers. |
void |
openPersistentEditor(QModelIndex index)
Opens a persistent editor on the item at the given index. |
void |
reset()
Reset the internal state of the view. |
QModelIndex |
rootIndex()
Returns the model index of the model's root item. |
protected void |
rowsAboutToBeRemoved(QModelIndex parent,
int start,
int end)
This slot is called when rows are about to be removed. |
protected void |
rowsInserted(QModelIndex parent,
int start,
int end)
This slot is called when rows are inserted. |
protected void |
scheduleDelayedItemsLayout()
Schedules a layout of the items in the view to be executed when the event processing starts. |
protected void |
scrollDirtyRegion(int dx,
int dy)
Prepares the view for scrolling by (dx,dy) pixels by moving the dirty regions in the opposite direction. |
void |
scrollTo(QModelIndex index)
Scrolls the view if necessary to ensure that the item at index is visible. |
abstract void |
scrollTo(QModelIndex index,
QAbstractItemView.ScrollHint hint)
Scrolls the view if necessary to ensure that the item at index is visible. |
void |
scrollToBottom()
Scrolls the view to the bottom. |
void |
scrollToTop()
Scrolls the view to the top. |
void |
selectAll()
Selects all item in the view. |
protected java.util.List |
selectedIndexes()
This convenience function returns a list of all selected and non-hidden item indexes in the view. |
QAbstractItemView.SelectionBehavior |
selectionBehavior()
This property holds which selection behavior the view uses. |
protected void |
selectionChanged(QItemSelection selected,
QItemSelection deselected)
This slot is called when the selection is changed. |
protected QItemSelectionModel.SelectionFlags |
selectionCommand(QModelIndex index)
Returns the SelectionFlags to be used when updating a selection with to include the index specified. |
protected QItemSelectionModel.SelectionFlags |
selectionCommand(QModelIndex index,
QEvent event)
Returns the SelectionFlags to be used when updating a selection with to include the index specified. |
QAbstractItemView.SelectionMode |
selectionMode()
This property holds which selection mode the view operates in. |
QItemSelectionModel |
selectionModel()
Returns the current selection model. |
void |
setAlternatingRowColors(boolean enable)
This property holds whether to draw the background using alternating colors. |
void |
setAutoScroll(boolean enable)
This property holds whether autoscrolling in drag move events is enabled. |
void |
setAutoScrollMargin(int margin)
This property holds the size of the area when auto scrolling is triggered. |
void |
setCurrentIndex(QModelIndex index)
Sets the current item to be the item at index. |
protected void |
setDirtyRegion(QRegion region)
Marks the given region as dirty and schedules it to be updated. |
void |
setDragDropMode(QAbstractItemView.DragDropMode behavior)
This property holds the drag and drop event the view will act upon. |
void |
setDragDropOverwriteMode(boolean overwrite)
This property holds the view's drag and drop behavior. |
void |
setDragEnabled(boolean enable)
This property holds whether the view supports dragging of its own items. |
void |
setDropIndicatorShown(boolean enable)
This property holds whether the drop indicator is shown when dragging items and dropping. |
void |
setEditTriggers(QAbstractItemView.EditTrigger[] triggers)
This property holds which actions will initiate item editing. |
void |
setEditTriggers(QAbstractItemView.EditTriggers triggers)
This property holds which actions will initiate item editing. |
void |
setHorizontalScrollMode(QAbstractItemView.ScrollMode mode)
This property holds how the view scrolls its contents in the horizontal direction. |
void |
setIconSize(QSize size)
This property holds the size of items. |
void |
setIndexWidget(QModelIndex index,
QWidget widget)
Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport. |
void |
setItemDelegate(QAbstractItemDelegate delegate)
Sets the item delegate for this view and its model to delegate. |
void |
setItemDelegateForColumn(int column,
QAbstractItemDelegate delegate)
Sets the given item delegate used by this view and model for the given column. |
void |
setItemDelegateForRow(int row,
QAbstractItemDelegate delegate)
Sets the given item delegate used by this view and model for the given row. |
void |
setModel(QAbstractItemModel model)
Sets the model for the view to present. |
void |
setRootIndex(QModelIndex index)
Sets the root item to the item at the given index. |
protected abstract void |
setSelection(QRect rect,
QItemSelectionModel.SelectionFlags command)
Applies the selection flags to the items in or touched by the rectangle, rect. |
void |
setSelectionBehavior(QAbstractItemView.SelectionBehavior behavior)
This property holds which selection behavior the view uses. |
void |
setSelectionMode(QAbstractItemView.SelectionMode mode)
This property holds which selection mode the view operates in. |
void |
setSelectionModel(QItemSelectionModel selectionModel)
Sets the current selection model to the given selectionModel. |
protected void |
setState(QAbstractItemView.State state)
Sets the item view's state to the given state. |
void |
setTabKeyNavigation(boolean enable)
This property holds whether item navigation with tab and backtab is enabled. |
void |
setTextElideMode(Qt.TextElideMode mode)
This property holds the the position of the ". |
void |
setVerticalScrollMode(QAbstractItemView.ScrollMode mode)
This property holds how the view scrolls its contents in the vertical direction. |
boolean |
showDropIndicator()
This property holds whether the drop indicator is shown when dragging items and dropping. |
int |
sizeHintForColumn(int column)
Returns the width size hint for the specified column or -1 if there is no model. |
QSize |
sizeHintForIndex(QModelIndex index)
Returns the size hint for the item with the specified index or an invalid size for invalid indexes. |
int |
sizeHintForRow(int row)
Returns the height size hint for the specified row or -1 if there is no model. |
protected void |
startDrag(Qt.DropAction[] supportedActions)
Starts a drag by calling drag-> exec() using the given supportedActions. |
protected void |
startDrag(Qt.DropActions supportedActions)
Starts a drag by calling drag-> exec() using the given supportedActions. |
protected QAbstractItemView.State |
state()
Returns the item view's state. |
boolean |
tabKeyNavigation()
This property holds whether item navigation with tab and backtab is enabled. |
Qt.TextElideMode |
textElideMode()
This property holds the the position of the ". |
void |
update(QModelIndex index)
Updates the area occupied by the given index. |
protected void |
updateGeometries()
Updates the geometry of the child widgets of the view. |
protected abstract int |
verticalOffset()
Returns the vertical offset of the view. |
QAbstractItemView.ScrollMode |
verticalScrollMode()
This property holds how the view scrolls its contents in the vertical direction. |
protected QStyleOptionViewItem |
viewOptions()
Returns a QStyleOptionViewItem structure populated with the view's palette, font, state, alignments etc. |
abstract QRect |
visualRect(QModelIndex index)
Returns the rectangle on the viewport occupied by the item at index. |
protected abstract QRegion |
visualRegionForSelection(QItemSelection selection)
Returns the region from the viewport of the items in the given selection. |
Methods inherited from class com.trolltech.qt.gui.QFrame |
---|
frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 activated
clicked()
, doubleClicked()
, entered()
, and pressed()
.
public final QSignalEmitter.Signal1 clicked
activated()
, doubleClicked()
, entered()
, and pressed()
.
public final QSignalEmitter.Signal1 doubleClicked
clicked()
, and activated()
.
public final QSignalEmitter.Signal1 entered
viewportEntered()
, activated()
, clicked()
, doubleClicked()
, and pressed()
.
public final QSignalEmitter.Signal1 pressed
Use the QApplication::mouseButtons()
function to get the state of the mouse buttons.
activated()
, clicked()
, doubleClicked()
, and entered()
.
public final QSignalEmitter.Signal0 viewportEntered
entered()
.
Constructor Detail |
---|
public QAbstractItemView()
public QAbstractItemView(QWidget parent)
Method Detail |
---|
public final boolean alternatingRowColors()
QPalette::Base
and QPalette::AlternateBase
; otherwise the background will be drawn using the QPalette::Base
color. By default, this property is false.
public final int autoScrollMargin()
public final void clearSelection()
setSelection()
, and selectAll()
.
public final void closePersistentEditor(QModelIndex index)
openPersistentEditor()
.
public final QModelIndex currentIndex()
setCurrentIndex()
.
protected final QPoint dirtyRegionOffset()
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.
scrollDirtyRegion()
, and setDirtyRegion()
.
public final QAbstractItemView.DragDropMode dragDropMode()
showDropIndicator
, and dragDropOverwriteMode
.
public final boolean dragDropOverwriteMode()
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.
Note: This is not intended to prevent overwriting of items. The model's implementation of flags() should do that by not returning Qt::ItemIsDropEnabled
.
dragDropMode
.
public final boolean dragEnabled()
showDropIndicator
, DragDropMode
, dragDropOverwriteMode
, and acceptDrops
.
protected final QAbstractItemView.DropIndicatorPosition dropIndicatorPosition()
public final void edit(QModelIndex index)
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.
public final QAbstractItemView.EditTriggers editTriggers()
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.
protected final void executeDelayedItemsLayout()
scheduleDelayedItemsLayout()
.
public final boolean hasAutoScroll()
QAbstractItemView
automatically scrolls the contents of the view if the user drags within 16 pixels of the viewport edge. If the current item changes, then the view will scroll automatically to ensure that the current item is fully visible. This property only works if the viewport accepts drops. Autoscroll is switched off by setting this property to false.
public final QAbstractItemView.ScrollMode horizontalScrollMode()
public final QSize iconSize()
public final QWidget indexWidget(QModelIndex index)
setIndexWidget()
.
public final QAbstractItemDelegate itemDelegate()
setItemDelegate()
, or the default one. setItemDelegate()
.
public final QAbstractItemDelegate itemDelegate(QModelIndex index)
public final QAbstractItemDelegate itemDelegateForColumn(int column)
itemDelegate()
to get a pointer to the current delegate for a given index. setItemDelegateForColumn()
, itemDelegateForRow()
, and itemDelegate()
.
public final QAbstractItemDelegate itemDelegateForRow(int row)
itemDelegate()
to get a pointer to the current delegate for a given index. setItemDelegateForRow()
, itemDelegateForColumn()
, and setItemDelegate()
.
public final QAbstractItemModel model()
setModel()
.
public final void openPersistentEditor(QModelIndex index)
closePersistentEditor()
.
public final QModelIndex rootIndex()
setRootIndex()
.
protected final void scheduleDelayedItemsLayout()
Even if scheduleDelayedItemsLayout()
is called multiple times before events are processed, the view will only do the layout once.
executeDelayedItemsLayout()
.
protected final void scrollDirtyRegion(int dx, int dy)
If you implement scrollContentsBy()
in a subclass of QAbstractItemView
, call this function before you call QWidget::scroll()
on the viewport. Alternatively, just call update()
.
scrollContentsBy()
, dirtyRegionOffset()
, and setDirtyRegion()
.
public final void scrollToBottom()
scrollTo()
, and scrollToTop()
.
public final void scrollToTop()
scrollTo()
, and scrollToBottom()
.
public final QAbstractItemView.SelectionBehavior selectionBehavior()
SelectionMode
, and SelectionBehavior
.
public final QAbstractItemView.SelectionMode selectionMode()
SelectionMode
, and SelectionBehavior
.
public final QItemSelectionModel selectionModel()
setSelectionModel()
, and selectedIndexes()
.
public final void setAlternatingRowColors(boolean enable)
QPalette::Base
and QPalette::AlternateBase
; otherwise the background will be drawn using the QPalette::Base
color. By default, this property is false.
public final void setAutoScroll(boolean enable)
QAbstractItemView
automatically scrolls the contents of the view if the user drags within 16 pixels of the viewport edge. If the current item changes, then the view will scroll automatically to ensure that the current item is fully visible. This property only works if the viewport accepts drops. Autoscroll is switched off by setting this property to false.
public final void setAutoScrollMargin(int margin)
public final void setCurrentIndex(QModelIndex index)
To set an item as the current item without selecting it, call
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
currentIndex()
, currentChanged()
, and selectionMode
.
protected final void setDirtyRegion(QRegion region)
scrollDirtyRegion()
, and dirtyRegionOffset()
.
public final void setDragDropMode(QAbstractItemView.DragDropMode behavior)
showDropIndicator
, and dragDropOverwriteMode
.
public final void setDragDropOverwriteMode(boolean overwrite)
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.
Note: This is not intended to prevent overwriting of items. The model's implementation of flags() should do that by not returning Qt::ItemIsDropEnabled
.
dragDropMode
.
public final void setDragEnabled(boolean enable)
showDropIndicator
, DragDropMode
, dragDropOverwriteMode
, and acceptDrops
.
public final void setDropIndicatorShown(boolean enable)
dragEnabled
, DragDropMode
, dragDropOverwriteMode
, and acceptDrops
.
public final void setEditTriggers(QAbstractItemView.EditTrigger[] triggers)
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.
public final void setEditTriggers(QAbstractItemView.EditTriggers triggers)
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.
public final void setHorizontalScrollMode(QAbstractItemView.ScrollMode mode)
public final void setIconSize(QSize size)
public final void setIndexWidget(QModelIndex index, QWidget widget)
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.
indexWidget()
, and Delegate Classes.
public final void setItemDelegate(QAbstractItemDelegate delegate)
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.
itemDelegate()
.
public final void setItemDelegateForColumn(int column, QAbstractItemDelegate delegate)
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.
itemDelegateForColumn()
, setItemDelegateForRow()
, and itemDelegate()
.
public final void setItemDelegateForRow(int row, QAbstractItemDelegate delegate)
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.
itemDelegateForRow()
, setItemDelegateForColumn()
, and itemDelegate()
.
public final void setSelectionBehavior(QAbstractItemView.SelectionBehavior behavior)
SelectionMode
, and SelectionBehavior
.
public final void setSelectionMode(QAbstractItemView.SelectionMode mode)
SelectionMode
, and SelectionBehavior
.
protected final void setState(QAbstractItemView.State state)
state()
.
public final void setTabKeyNavigation(boolean enable)
public final void setTextElideMode(Qt.TextElideMode mode)
Qt::ElideRight
.
public final void setVerticalScrollMode(QAbstractItemView.ScrollMode mode)
public final boolean showDropIndicator()
dragEnabled
, DragDropMode
, dragDropOverwriteMode
, and acceptDrops
.
public final QSize sizeHintForIndex(QModelIndex index)
sizeHintForRow()
, and sizeHintForColumn()
.
protected final QAbstractItemView.State state()
setState()
.
public final boolean tabKeyNavigation()
public final Qt.TextElideMode textElideMode()
Qt::ElideRight
.
public final void update(QModelIndex index)
public final QAbstractItemView.ScrollMode verticalScrollMode()
protected void closeEditor(QWidget editor, QAbstractItemDelegate.EndEditHint hint)
edit()
, and commitData()
.
protected void commitData(QWidget editor)
closeEditor()
.
protected void currentChanged(QModelIndex current, QModelIndex previous)
If you want to know about changes to items see the dataChanged()
signal.
protected void dataChanged(QModelIndex topLeft, QModelIndex bottomRight)
protected boolean edit(QModelIndex index, QAbstractItemView.EditTrigger trigger, QEvent event)
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
.
closeEditor()
.
protected void editorDestroyed(QObject editor)
closeEditor()
.
protected abstract int horizontalOffset()
In the base class this is a pure virtual function.
verticalOffset()
.
public abstract QModelIndex indexAt(QPoint point)
In the base class this is a pure virtual function.
visualRect()
.
protected abstract boolean isIndexHidden(QModelIndex index)
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.
public void keyboardSearch(java.lang.String search)
In the default implementation, the search is reset if search is empty, or the time interval since the last search has exceeded QApplication::keyboardInputInterval()
.
protected abstract QModelIndex moveCursor(QAbstractItemView.CursorAction cursorAction, Qt.KeyboardModifiers modifiers)
In the base class this is a pure virtual function.
public void reset()
Warning: This function will reset open editors, scroll bar positions, selections, etc. Existing changes will not be committed. If you would like to save your changes when resetting the view, you can reimplement this function, commit your changes, and then call the superclass' implementation.
protected void rowsAboutToBeRemoved(QModelIndex parent, int start, int end)
rowsInserted()
.
protected void rowsInserted(QModelIndex parent, int start, int end)
fetchMore()
on the model to check for more data. rowsAboutToBeRemoved()
.
public final void scrollTo(QModelIndex index)
In the base class this is a pure virtual function.
public abstract void scrollTo(QModelIndex index, QAbstractItemView.ScrollHint hint)
In the base class this is a pure virtual function.
public void selectAll()
setSelection()
, selectedIndexes()
, and clearSelection()
.
protected java.util.List selectedIndexes()
The default implementation does nothing.
QItemSelectionModel::selectedIndexes()
.
protected void selectionChanged(QItemSelection selected, QItemSelection deselected)
setSelection()
.
protected final QItemSelectionModel.SelectionFlags selectionCommand(QModelIndex index)
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.
setSelection()
.
protected QItemSelectionModel.SelectionFlags selectionCommand(QModelIndex index, QEvent event)
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.
setSelection()
.
public void setModel(QAbstractItemModel model)
Note: The view does not take ownership of the model unless it is the model's parent object because it may be shared between many different views.
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.
model()
, selectionModel()
, and setSelectionModel()
.
public void setRootIndex(QModelIndex index)
rootIndex()
.
protected abstract void setSelection(QRect rect, QItemSelectionModel.SelectionFlags command)
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.
selectionCommand()
, and selectedIndexes()
.
public void setSelectionModel(QItemSelectionModel selectionModel)
Note that, if you call setModel()
after this function, the given selectionModel will be replaced by one created by the view.
selectionModel()
, setModel()
, and clearSelection()
.
public int sizeHintForColumn(int column)
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.
sizeHintForRow()
.
public int sizeHintForRow(int row)
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.
sizeHintForColumn()
.
protected final void startDrag(Qt.DropAction[] supportedActions)
exec()
using the given supportedActions.
protected void startDrag(Qt.DropActions supportedActions)
exec()
using the given supportedActions.
protected void updateGeometries()
protected abstract int verticalOffset()
In the base class this is a pure virtual function.
horizontalOffset()
.
protected QStyleOptionViewItem viewOptions()
QStyleOptionViewItem
structure populated with the view's palette, font, state, alignments etc.
public abstract QRect visualRect(QModelIndex 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.
indexAt()
, and visualRegionForSelection()
.
protected abstract QRegion visualRegionForSelection(QItemSelection selection)
In the base class this is a pure virtual function.
visualRect()
, and selectedIndexes()
.
public static QAbstractItemView fromNativePointer(QNativePointer nativePointer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |