|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.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
com.trolltech.qt.gui.QTableView
public class QTableView
The QTableView class provides a default model/view implementation of a table view. A QTableView implements a table view that displays items from a model. This class is used to provide standard tables that were previously provided by the QTable class, but using the more flexible approach provided by Qt's model/view architecture.
The QTableView class is one of the Model/View Classes and is part of Qt's model/view framework.
QTableView implements the interfaces defined by the QAbstractItemView
class to allow it to display data provided by models derived from the QAbstractItemModel
class.Navigation
You can navigate the cells in the table by clicking on a cell with the mouse, or by using the arrow keys. Because QTableView enables tabKeyNavigation
by default, you can also hit Tab and Backtab to move from cell to cell.Visual Appearance
The table has a vertical header that can be obtained using the verticalHeader()
function, and a horizontal header that is available through the horizontalHeader()
function. The height of each row in the table can be found by using rowHeight()
; similarly, the width of columns can be found using columnWidth()
. Since both of these are plain widgets, you can hide either of them using their hide()
functions.
Rows and columns can be hidden and shown with hideRow()
, hideColumn()
, showRow()
, and showColumn()
. They can be selected with selectRow()
and selectColumn()
. The table will show a grid depending on the showGrid
property.
The items shown in a table view, like those in the other item views, are rendered and edited using standard delegates
. However, for some tasks it is sometimes useful to be able to insert widgets in a table instead. Widgets are set for particular indexes with the setIndexWidget()
function, and later retrieved with indexWidget()
.
![]() | By default, the cells in a table do not expand to fill the available space. You can make the cells fill the available space by stretching the last header section. Access the relevant header using To distribute the available space according to the space requirement of each column or row, call the view's |
rowAt()
function provides the y-coordinate within the view of the specified row; the row index can be used to obtain a corresponding y-coordinate with rowViewportPosition()
. The columnAt()
and columnViewportPosition()
functions provide the equivalent conversion operations between x-coordinates and column indexes. ![]() | ![]() | ![]() |
A Windows XP style table view. | A Macintosh style table view. | A Plastique style table view. |
QTableWidget
, View Classes, QAbstractItemModel
, QAbstractItemView
, Chart Example, Pixelator Example, and Table Model Example.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractItemView |
---|
QAbstractItemView.CursorAction, QAbstractItemView.DragDropMode, QAbstractItemView.DropIndicatorPosition, QAbstractItemView.EditTrigger, QAbstractItemView.EditTriggers, QAbstractItemView.ScrollHint, QAbstractItemView.ScrollMode, QAbstractItemView.SelectionBehavior, QAbstractItemView.SelectionMode, QAbstractItemView.State |
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.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.gui.QAbstractItemView |
---|
activated, clicked, doubleClicked, entered, pressed, viewportEntered |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QTableView()
Constructs a table view with a parent to represent the data. |
|
QTableView(QWidget parent)
Constructs a table view with a parent to represent the data. |
Method Summary | |
---|---|
void |
clearSpans()
Removes all row and column spans in the table view. |
int |
columnAt(int x)
Returns the column in which the given x-coordinate, x, in contents coordinates is located. |
protected void |
columnCountChanged(int oldCount,
int newCount)
This slot is called whenever columns are added or deleted. |
protected void |
columnMoved(int column,
int oldIndex,
int newIndex)
This slot is called to change the index of the given column in the table view. |
protected void |
columnResized(int column,
int oldWidth,
int newWidth)
This slot is called to change the width of the given column. |
int |
columnSpan(int row,
int column)
Returns the column span of the table element at (row, column). |
int |
columnViewportPosition(int column)
Returns the x-coordinate in contents coordinates of the given column. |
int |
columnWidth(int column)
Returns the width of the given column. |
Qt.PenStyle |
gridStyle()
This property holds the pen style used to draw the grid. |
void |
hideColumn(int column)
Hide the given column. |
void |
hideRow(int row)
Hide the given row. |
QHeaderView |
horizontalHeader()
Returns the table view's horizontal header. |
boolean |
isColumnHidden(int column)
Returns true if the given column is hidden; otherwise returns false. |
boolean |
isCornerButtonEnabled()
This property holds whether the button in the top-left corner is enabled. |
boolean |
isRowHidden(int row)
Returns true if the given row is hidden; otherwise returns false. |
boolean |
isSortingEnabled()
This property holds whether sorting is enabled. |
void |
resizeColumnsToContents()
Resizes all columns based on the size hints of the delegate used to render each item in the columns. |
void |
resizeColumnToContents(int column)
Resizes the given column based on the size hints of the delegate used to render each item in the column. |
void |
resizeRowsToContents()
Resizes all rows based on the size hints of the delegate used to render each item in the rows. |
void |
resizeRowToContents(int row)
Resizes the given row based on the size hints of the delegate used to render each item in the row. |
int |
rowAt(int y)
Returns the row in which the given y-coordinate, y, in contents coordinates is located. |
protected void |
rowCountChanged(int oldCount,
int newCount)
This slot is called whenever rows are added or deleted. |
int |
rowHeight(int row)
Returns the height of the given row. |
protected void |
rowMoved(int row,
int oldIndex,
int newIndex)
This slot is called to change the index of the given row in the table view. |
protected void |
rowResized(int row,
int oldHeight,
int newHeight)
This slot is called to change the height of the given row. |
int |
rowSpan(int row,
int column)
Returns the row span of the table element at (row, column). |
int |
rowViewportPosition(int row)
Returns the y-coordinate in contents coordinates of the given row. |
void |
selectColumn(int column)
Selects the given column in the table view if the current SelectionMode and SelectionBehavior allows columns to be selected. |
void |
selectRow(int row)
Selects the given row in the table view if the current SelectionMode and SelectionBehavior allows rows to be selected. |
void |
setColumnHidden(int column,
boolean hide)
If hide is true the given column will be hidden; otherwise it will be shown. |
void |
setColumnWidth(int column,
int width)
Sets the width of the given column to be width. |
void |
setCornerButtonEnabled(boolean enable)
This property holds whether the button in the top-left corner is enabled. |
void |
setGridStyle(Qt.PenStyle style)
This property holds the pen style used to draw the grid. |
void |
setHorizontalHeader(QHeaderView header)
Sets the widget to use for the horizontal header to header. |
void |
setRowHeight(int row,
int height)
Sets the height of the given row to be height. |
void |
setRowHidden(int row,
boolean hide)
If hide is true row will be hidden, otherwise it will be shown. |
void |
setShowGrid(boolean show)
This property holds whether the grid is shown. |
void |
setSortingEnabled(boolean enable)
This property holds whether sorting is enabled. |
void |
setSpan(int row,
int column,
int rowSpan,
int columnSpan)
Sets the span of the table element at (row, column) to the number of rows and columns specified by (rowSpanCount, columnSpanCount). |
void |
setVerticalHeader(QHeaderView header)
Sets the widget to use for the vertical header to header. |
void |
setWordWrap(boolean on)
This property holds the item text word-wrapping policy. |
void |
showColumn(int column)
Show the given column. |
boolean |
showGrid()
This property holds whether the grid is shown. |
void |
showRow(int row)
Show the given row. |
void |
sortByColumn(int column,
Qt.SortOrder order)
Sorts the model by the values in the given column in the given order. |
QHeaderView |
verticalHeader()
Returns the table view's vertical header. |
boolean |
wordWrap()
This property holds the item text word-wrapping policy. |
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 com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
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 |
Constructor Detail |
---|
public QTableView()
QAbstractItemModel
.
public QTableView(QWidget parent)
QAbstractItemModel
.
Method Detail |
---|
public final void clearSpans()
setSpan()
.
public final int columnAt(int x)
Note: This function returns -1 if the given coordinate is not valid (has no column).
rowAt()
.
protected final void columnCountChanged(int oldCount, int newCount)
protected final void columnMoved(int column, int oldIndex, int newIndex)
rowMoved()
.
protected final void columnResized(int column, int oldWidth, int newWidth)
rowResized()
.
public final int columnSpan(int row, int column)
setSpan()
, and rowSpan()
.
public final int columnViewportPosition(int column)
public final int columnWidth(int column)
setColumnWidth()
, resizeColumnToContents()
, and rowHeight()
.
public final Qt.PenStyle gridStyle()
showGrid
).
public final void hideColumn(int column)
showColumn()
, and hideRow()
.
public final void hideRow(int row)
showRow()
, and hideColumn()
.
public final QHeaderView horizontalHeader()
setHorizontalHeader()
, verticalHeader()
, and QAbstractItemModel::headerData()
.
public final boolean isColumnHidden(int column)
isRowHidden()
.
public final boolean isCornerButtonEnabled()
This property is true by default.
public final boolean isRowHidden(int row)
isColumnHidden()
.
public final boolean isSortingEnabled()
sortByColumn()
.
public final void resizeColumnToContents(int column)
public final void resizeColumnsToContents()
public final void resizeRowToContents(int row)
public final void resizeRowsToContents()
public final int rowAt(int y)
Note: This function returns -1 if the given coordinate is not valid (has no row).
columnAt()
.
protected final void rowCountChanged(int oldCount, int newCount)
public final int rowHeight(int row)
setRowHeight()
, resizeRowToContents()
, and columnWidth()
.
protected final void rowMoved(int row, int oldIndex, int newIndex)
columnMoved()
.
protected final void rowResized(int row, int oldHeight, int newHeight)
columnResized()
.
public final int rowSpan(int row, int column)
setSpan()
, and columnSpan()
.
public final int rowViewportPosition(int row)
public final void selectColumn(int column)
SelectionMode
and SelectionBehavior
allows columns to be selected. selectRow()
.
public final void selectRow(int row)
SelectionMode
and SelectionBehavior
allows rows to be selected. selectColumn()
.
public final void setColumnHidden(int column, boolean hide)
isColumnHidden()
, and setRowHidden()
.
public final void setColumnWidth(int column, int width)
columnWidth()
.
public final void setCornerButtonEnabled(boolean enable)
This property is true by default.
public final void setGridStyle(Qt.PenStyle style)
showGrid
).
public final void setHorizontalHeader(QHeaderView header)
horizontalHeader()
, and setVerticalHeader()
.
public final void setRowHeight(int row, int height)
rowHeight()
.
public final void setRowHidden(int row, boolean hide)
isRowHidden()
, and setColumnHidden()
.
public final void setShowGrid(boolean show)
public final void setSortingEnabled(boolean enable)
sortByColumn()
.
public final void setSpan(int row, int column, int rowSpan, int columnSpan)
rowSpan()
, and columnSpan()
.
public final void setVerticalHeader(QHeaderView header)
verticalHeader()
, and setHorizontalHeader()
.
public final void setWordWrap(boolean on)
Note that even of wrapping is enabled, the cell will not be expanded to fit all text. Ellipsis will be inserted according to the current textElideMode
.
public final void showColumn(int column)
hideColumn()
, and showRow()
.
public final boolean showGrid()
public final void showRow(int row)
hideRow()
, and showColumn()
.
public final void sortByColumn(int column, Qt.SortOrder order)
sortingEnabled
.
public final QHeaderView verticalHeader()
setVerticalHeader()
, horizontalHeader()
, and QAbstractItemModel::headerData()
.
public final boolean wordWrap()
Note that even of wrapping is enabled, the cell will not be expanded to fit all text. Ellipsis will be inserted according to the current textElideMode
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |