Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

Q3Table Class

TheQ3Table class provides a flexible editable table widget.More...

Header:#include <Q3Table>
Inherits:Q3ScrollView
Inherited By:

Q3DataTable

Public Types

enumFocusStyle { FollowStyle, SpreadSheet }
enumSelectionMode { NoSelection, Single, Multi, SingleRow, MultiRow }

Properties

Public Functions

Q3Table(QWidget * parent = 0, const char * name = 0)
Q3Table(int numRows, int numCols, QWidget * parent = 0, const char * name = 0)
~Q3Table()
virtual intaddSelection(const Q3TableSelection & s)
virtual QRectcellGeometry(int row, int col) const
virtual QRectcellRect(int row, int col) const
virtual QWidget *cellWidget(int row, int col) const
virtual voidclearCell(int row, int col)
virtual voidclearCellWidget(int row, int col)
virtual intcolumnAt(int x) const
boolcolumnMovingEnabled() const
virtual intcolumnPos(int col) const
virtual intcolumnWidth(int col) const
intcurrentColumn() const
intcurrentRow() const
virtual intcurrentSelection() const
booldragEnabled() const
voidensureCellVisible(int row, int col)
FocusStylefocusStyle() const
Q3Header *horizontalHeader() const
boolisColumnHidden(int col) const
boolisColumnReadOnly(int col) const
boolisColumnSelected(int col, bool full = false) const
boolisColumnStretchable(int col) const
boolisReadOnly() const
boolisRowHidden(int row) const
boolisRowReadOnly(int row) const
boolisRowSelected(int row, bool full = false) const
boolisRowStretchable(int row) const
boolisSelected(int row, int col) const
virtual Q3TableItem *item(int row, int col) const
virtual intnumCols() const
virtual intnumRows() const
intnumSelections() const
virtual voidpaintCell(QPainter * p, int row, int col, const QRect & cr, bool selected, const QColorGroup & cg)
virtual voidpaintCell(QPainter * p, int row, int col, const QRect & cr, bool selected)
virtual voidpaintFocus(QPainter * p, const QRect & cr)
virtual QPixmappixmap(int row, int col) const
virtual voidremoveSelection(const Q3TableSelection & s)
virtual voidremoveSelection(int num)
voidrepaintSelections()
virtual introwAt(int y) const
virtual introwHeight(int row) const
boolrowMovingEnabled() const
virtual introwPos(int row) const
voidselectCells(int start_row, int start_col, int end_row, int end_col)
virtual voidselectColumn(int col)
virtual voidselectRow(int row)
Q3TableSelectionselection(int num) const
SelectionModeselectionMode() const
virtual voidsetCellWidget(int row, int col, QWidget * e)
virtual voidsetFocusStyle(FocusStyle fs)
virtual voidsetItem(int row, int col, Q3TableItem * item)
virtual voidsetPixmap(int row, int col, const QPixmap & pix)
virtual voidsetSelectionMode(SelectionMode mode)
virtual voidsetText(int row, int col, const QString & text)
boolshowGrid() const
virtual voidsortColumn(int col, bool ascending = true, bool wholeRows = false)
boolsorting() const
virtual voidtakeItem(Q3TableItem * i)
virtual QStringtext(int row, int col) const
voidupdateCell(int row, int col)
voidupdateHeaderStates()
Q3Header *verticalHeader() const

Reimplemented Public Functions

virtual booleventFilter(QObject * o, QEvent * e)
virtual QVariantinputMethodQuery(Qt::InputMethodQuery query) const
virtual QSizesizeHint() const
  • 49 public functions inherited fromQ3ScrollView
  • 4 public functions inherited fromQ3Frame
  • 14 public functions inherited fromQFrame
  • 220 public functions inherited fromQWidget
  • 29 public functions inherited fromQObject
  • 12 public functions inherited fromQPaintDevice

Public Slots

virtual voidadjustColumn(int col)
virtual voidadjustRow(int row)
voidclearSelection(bool repaint = true)
virtual voideditCell(int row, int col, bool replace = false)
virtual voidhideColumn(int col)
virtual voidhideRow(int row)
virtual voidinsertColumns(int col, int count = 1)
virtual voidinsertRows(int row, int count = 1)
virtual voidremoveColumn(int col)
virtual voidremoveColumns(const Q3MemArray<int> & cols)
virtual voidremoveRow(int row)
virtual voidremoveRows(const Q3MemArray<int> & rows)
voidsetColumnLabels(const QStringList & labels)
virtual voidsetColumnMovingEnabled(bool b)
virtual voidsetColumnReadOnly(int col, bool ro)
virtual voidsetColumnStretchable(int col, bool stretch)
virtual voidsetColumnWidth(int col, int w)
virtual voidsetCurrentCell(int row, int col)
virtual voidsetDragEnabled(bool b)
virtual voidsetLeftMargin(int m)
virtual voidsetNumCols(int r)
virtual voidsetNumRows(int r)
virtual voidsetReadOnly(bool b)
virtual voidsetRowHeight(int row, int h)
voidsetRowLabels(const QStringList & labels)
virtual voidsetRowMovingEnabled(bool b)
virtual voidsetRowReadOnly(int row, bool ro)
virtual voidsetRowStretchable(int row, bool stretch)
virtual voidsetShowGrid(bool b)
virtual voidsetSorting(bool b)
virtual voidsetTopMargin(int m)
virtual voidshowColumn(int col)
virtual voidshowRow(int row)
virtual voidswapCells(int row1, int col1, int row2, int col2)
virtual voidswapColumns(int col1, int col2, bool swapHeader = false)
virtual voidswapRows(int row1, int row2, bool swapHeader = false)

Signals

voidclicked(int row, int col, int button, const QPoint & mousePos)
voidcontextMenuRequested(int row, int col, const QPoint & pos)
voidcurrentChanged(int row, int col)
voiddoubleClicked(int row, int col, int button, const QPoint & mousePos)
voiddropped(QDropEvent * e)
voidpressed(int row, int col, int button, const QPoint & mousePos)
voidselectionChanged()
voidvalueChanged(int row, int col)

Protected Types

enumEditMode { NotEditing, Editing, Replacing }

Protected Functions

virtual voidactivateNextCell()
virtual QWidget *beginEdit(int row, int col, bool replace)
virtual QWidget *createEditor(int row, int col, bool initFromCell) const
intcurrEditCol() const
intcurrEditRow() const
virtual Q3DragObject *dragObject()
EditModeeditMode() const
virtual voidendEdit(int row, int col, bool accept, bool replace)
intindexOf(int row, int col) const
virtual voidinsertWidget(int row, int col, QWidget * w)
boolisEditing() const
virtual voidpaintEmptyArea(QPainter * p, int cx, int cy, int cw, int ch)
virtual voidresizeData(int len)
virtual voidsetCellContentFromEditor(int row, int col)
voidsetEditMode(EditMode mode, int row, int col)
virtual voidstartDrag()

Reimplemented Protected Functions

virtual voidcontentsContextMenuEvent(QContextMenuEvent * e)
virtual voidcontentsDragEnterEvent(QDragEnterEvent * e)
virtual voidcontentsDragLeaveEvent(QDragLeaveEvent * e)
virtual voidcontentsDragMoveEvent(QDragMoveEvent * e)
virtual voidcontentsDropEvent(QDropEvent * e)
virtual voidcontentsMouseDoubleClickEvent(QMouseEvent * e)
virtual voidcontentsMouseMoveEvent(QMouseEvent * e)
virtual voidcontentsMousePressEvent(QMouseEvent * e)
virtual voidcontentsMouseReleaseEvent(QMouseEvent * e)
virtual voiddrawContents(QPainter * p, int cx, int cy, int cw, int ch)
virtual voidfocusInEvent(QFocusEvent *)
virtual voidfocusOutEvent(QFocusEvent * e)
virtual voidkeyPressEvent(QKeyEvent * e)
virtual voidpaintEvent(QPaintEvent * e)
virtual voidshowEvent(QShowEvent * e)
virtual voidviewportResizeEvent(QResizeEvent * e)
  • 26 protected functions inherited fromQ3ScrollView
  • 5 protected functions inherited fromQ3Frame
  • 3 protected functions inherited fromQFrame
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Protected Slots

virtual voidcolumnClicked(int col)
virtual voidcolumnIndexChanged(int section, int fromIndex, int toIndex)
virtual voidcolumnWidthChanged(int col)
virtual voidrowHeightChanged(int row)
virtual voidrowIndexChanged(int section, int fromIndex, int toIndex)
  • 1 protected slot inherited fromQWidget

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject

Detailed Description

TheQ3Table class provides a flexible editable table widget.

Q3Table is easy to use, although it does have a large API because of the comprehensive functionality that it provides.Q3Table includes functions for manipulatingheaders,rows and columns,cells andselections.Q3Table also provides in-place editing and drag and drop, as well as a useful set ofsignals.Q3Table efficiently supports very large tables, for example, tables one million by one million cells are perfectly possible.Q3Table is economical with memory, using none for unused cells.

Q3Table*table=newQ3Table(100,250,this);table->setPixmap(3,2, pix);table->setText(3,2,"A pixmap");

The first line constructs the table specifying its size in rows and columns. We then insert a pixmap and some text into thesamecell, with the pixmap appearing to the left of the text.Q3Table cells can be populated withQ3TableItems,Q3ComboTableItems or byQ3CheckTableItems. By default a vertical header appears at the left of the table showing row numbers and a horizontal header appears at the top of the table showing column numbers. (The numbers displayed start at 1, although row and column numbers withinQ3Table begin at 0.)

If you want to use mouse tracking callsetMouseTracking(true) on theviewport.

Table Items

Headers

Q3Table supports a header column, e.g. to display row numbers, and a header row, e.g to display column titles. To set row or column labels useQ3Header::setLabel() on the pointers returned byverticalHeader() andhorizontalHeader() respectively. The vertical header is displayed within the table's left margin whose width is set withsetLeftMargin(). The horizontal header is displayed within the table's top margin whose height is set withsetTopMargin(). The table's grid can be switched off withsetShowGrid(). If you want to hide a horizontal header callhide(), and callsetTopMargin(0) so that the area the header would have occupied is reduced to zero size.

Header labels are indexed via their section numbers. Note that the default behavior ofQ3Header regarding section numbers is overridden forQ3Table. See the explanation below in the Rows and Columns section in the discussion of moving columns and rows.

Rows and Columns

Row and column sizes are set withsetRowHeight() andsetColumnWidth(). If you want a row high enough to show the tallest item in its entirety, useadjustRow(). Similarly, to make a column wide enough to show the widest item useadjustColumn(). If you want the row height and column width to adjust automatically as the height and width of the table changes usesetRowStretchable() andsetColumnStretchable().

Rows and columns can be hidden and shown withhideRow(),hideColumn(),showRow() andshowColumn(). New rows and columns are inserted usinginsertRows() andinsertColumns(). Additional rows and columns are added at the bottom (rows) or right (columns) if you setsetNumRows() orsetNumCols() to be larger thannumRows() ornumCols(). Existing rows and columns are removed withremoveRow() andremoveColumn(). Multiple rows and columns can be removed withremoveRows() andremoveColumns().

Rows and columns can be set to be movable usingrowMovingEnabled() andcolumnMovingEnabled(). The user can drag them to reorder them holding down the Ctrl key and dragging the mouse. For performance reasons, the default behavior ofQ3Header section numbers is overridden byQ3Table. Currently inQ3Table, when a row or column is dragged and reordered, the section number is also changed to its new position. Therefore, there is no difference between the section and the index fields inQ3Header. TheQ3TableQ3Header classes do not provide a mechanism for indexing independently of the user interface ordering.

The table can be sorted usingsortColumn(). Users can sort a column by clicking its header ifsetSorting() is set to true. Rows can be swapped withswapRows(), columns withswapColumns() and cells withswapCells().

For editable tables (seesetReadOnly()) you can set the read-only property of individual rows and columns withsetRowReadOnly() andsetColumnReadOnly(). (Whether a cell is editable or read-only depends on these settings and the cell'sQ3TableItem.

The row and column which have the focus are returned bycurrentRow() andcurrentColumn() respectively.

Although manyQ3Table functions operate in terms of rows and columns theindexOf() function returns a single integer identifying a particular cell.

Cells

All of aQ3Table's cells are empty when the table is constructed.

There are two approaches to populating the table's cells. The first and simplest approach is to use Q3TableItems orQ3TableItem subclasses. The second approach doesn't use Q3TableItems at all which is useful for very large sparse tables but requires you to reimplement a number of functions. We'll look at each approach in turn.

To put a string in a cell usesetText(). This function will create a newQ3TableItem for the cell if one doesn't already exist, and displays the text in it. By default the table item's widget will be aQLineEdit. A pixmap may be put in a cell withsetPixmap(), which also creates a table item if required. A cell may containboth a pixmap and text; the pixmap is displayed to the left of the text. Another approach is to construct aQ3TableItem orQ3TableItem subclass, set its properties, then insert it into a cell withsetItem().

If you want cells which contain comboboxes use theQ3ComboTableItem class. Similarly if you require cells containing checkboxes use theQ3CheckTableItem class. These table items look and behave just like the combobox or checkbox widgets but consume far less memory.

Q3Table takes ownership of its Q3TableItems and will delete them when the table itself is destroyed. You can take ownership of a table item usingtakeItem() which you use to move a cell's contents from one cell to another, either within the same table, or from one table to another. (See also,swapCells()).

In-place editing of the text in Q3TableItems, and the values in Q3ComboTableItems and Q3CheckTableItems works automatically. Cells may be editable or read-only, seeQ3TableItem::EditType. If you want fine control over editing seebeginEdit() andendEdit().

The contents of a cell can be retrieved as aQ3TableItem usingitem(), or as a string withtext() or as a pixmap (if there is one) withpixmap(). A cell's bounding rectangle is given bycellGeometry(). UseupdateCell() to repaint a cell, for example to clear away a cell's visual representation after it has been deleted withclearCell(). The table can be forced to scroll to show a particular cell withensureCellVisible(). TheisSelected() function indicates if a cell is selected.

It is possible to use your own widget as a cell's widget usingsetCellWidget(), but subclassingQ3TableItem might be a simpler approach. The cell's widget (if there is one) can be removed withclearCellWidget().

Large tables

For large, sparse, tables using Q3TableItems or other widgets is inefficient. The solution is todraw the cell as it should appear and to create and destroy cell editors on demand.

This approach requires that you reimplement various functions. ReimplementpaintCell() to display your data, andcreateEditor() andsetCellContentFromEditor() to support in-place editing. It is very important to reimplementresizeData() to have no functionality, to preventQ3Table from attempting to create a huge array. You will also need to reimplementitem(),setItem(),takeItem(),clearCell(), andinsertWidget(),cellWidget() andclearCellWidget(). In almost every circumstance (for sorting, removing and inserting columns and rows, etc.), you also need to reimplementswapRows(),swapCells() andswapColumns(), including header handling.

If you represent active cells with a dictionary of Q3TableItems and QWidgets, i.e. only store references to cells that are actually used, many of the functions can be implemented with a single line of code.

For more information on cells see theQ3TableItem documenation.

Selections

Q3Table's support single selection, multi-selection (multiple cells) or no selection. The selection mode is set withsetSelectionMode(). UseisSelected() to determine if a particular cell is selected, andisRowSelected() andisColumnSelected() to see if a row or column is selected.

Q3Table's support many simultaneous selections. You can programmatically select cells withaddSelection(). The number of selections is given bynumSelections(). The current selection is returned bycurrentSelection(). You can remove a selection withremoveSelection() and remove all selections withclearSelection(). Selections areQ3TableSelection objects.

To easily add a new selection useselectCells(),selectRow() orselectColumn().

Alternatively, useaddSelection() to add new selections usingQ3TableSelection objects. The advantage of usingQ3TableSelection objects is that you can callQ3TableSelection::expandTo() to resize the selection and can query and compare them.

The number of selections is given bynumSelections(). The current selection is returned bycurrentSelection(). You can remove a selection withremoveSelection() and remove all selections withclearSelection().

Signals

When the user clicks a cell thecurrentChanged() signal is emitted. You can also connect to the lower levelclicked(),doubleClicked() andpressed() signals. If the user changes the selection theselectionChanged() signal is emitted; similarly if the user changes a cell's value thevalueChanged() signal is emitted. If the user right-clicks (or presses the appropriate platform-specific key sequence) thecontextMenuRequested() signal is emitted. If the user drops a drag and drop object thedropped() signal is emitted with the drop event.

Member Type Documentation

enum Q3Table::EditMode

ConstantValueDescription
Q3Table::NotEditing0No cell is currently being edited.
Q3Table::Editing1A cell is currently being edited. The editor was initialised with the cell's contents.
Q3Table::Replacing2A cell is currently being edited. The editor was not initialised with the cell's contents.

enum Q3Table::FocusStyle

Specifies how the current cell (focus cell) is drawn.

ConstantValueDescription
Q3Table::FollowStyle0The current cell is drawn according to the current style and the cell's background is also drawn selected, if the current cell is within a selection
Q3Table::SpreadSheet1The current cell is drawn as in a spreadsheet. This means, it is signified by a black rectangle around the cell, and the background of the current cell is always drawn with the widget's base color - even when selected.

enum Q3Table::SelectionMode

ConstantValueDescription
Q3Table::NoSelection4No cell can be selected by the user.
Q3Table::Single0The user may only select a single range of cells.
Q3Table::Multi1The user may select multiple ranges of cells.
Q3Table::SingleRow2The user may select one row at once.
Q3Table::MultiRow3The user may select multiple rows.

Property Documentation

columnMovingEnabled :bool

This property holds whether columns can be moved by the user.

The default is false. Columns are moved by dragging whilst holding down the Ctrl key.

Access functions:

boolcolumnMovingEnabled() const
virtual voidsetColumnMovingEnabled(bool b)

See alsorowMovingEnabled.

focusStyle :FocusStyle

This property holds how the current (focus) cell is drawn.

The default style isSpreadSheet.

Access functions:

FocusStylefocusStyle() const
virtual voidsetFocusStyle(FocusStyle fs)

See alsoQ3Table::FocusStyle.

numCols :int

This property holds the number of columns in the table.

Access functions:

virtual intnumCols() const
virtual voidsetNumCols(int r)

See alsonumRows.

numRows :int

This property holds the number of rows in the table.

Access functions:

virtual intnumRows() const
virtual voidsetNumRows(int r)

See alsonumCols.

numSelections : constint

This property holds the number of selections.

Access functions:

intnumSelections() const

See alsocurrentSelection().

readOnly :bool

This property holds whether the table is read-only.

Whether a cell in the table is editable or read-only depends on the cell'sEditType, and this setting.

Access functions:

boolisReadOnly() const
virtual voidsetReadOnly(bool b)

See alsoQWidget::enabled,setColumnReadOnly(), andsetRowReadOnly().

rowMovingEnabled :bool

This property holds whether rows can be moved by the user.

The default is false. Rows are moved by dragging whilst holding down the Ctrl key.

Access functions:

boolrowMovingEnabled() const
virtual voidsetRowMovingEnabled(bool b)

See alsocolumnMovingEnabled.

selectionMode :SelectionMode

This property holds the current selection mode.

The default mode isMulti which allows the user to select multiple ranges of cells.

Access functions:

SelectionModeselectionMode() const
virtual voidsetSelectionMode(SelectionMode mode)

showGrid :bool

This property holds whether the table's grid is displayed.

The grid is shown by default.

Access functions:

boolshowGrid() const
virtual voidsetShowGrid(bool b)

sorting :bool

This property holds whether a click on the header of a column sorts that column.

Access functions:

boolsorting() const
virtual voidsetSorting(bool b)

See alsosortColumn().

Member Function Documentation

Q3Table::Q3Table(QWidget * parent = 0, constchar * name = 0)

Creates an empty table object calledname as a child ofparent.

CallsetNumRows() andsetNumCols() to set the table size before populating the table if you're using Q3TableItems.

Q3Table::Q3Table(int numRows,int numCols,QWidget * parent = 0, constchar * name = 0)

Constructs an empty table calledname withnumRows rows andnumCols columns. The table is a child ofparent.

If you're usingQ3TableItems to populate the table's cells, you can createQ3TableItem,Q3ComboTableItem andQ3CheckTableItem items and insert them into the table usingsetItem(). (See the notes on large tables for an alternative to using Q3TableItems.)

Q3Table::~Q3Table()

Releases all the resources used by theQ3Table object, including allQ3TableItems and their widgets.

[virtual protected]void Q3Table::activateNextCell()

This function is called to activate the next cell if in-place editing was finished by pressing the Enter key.

The default behaviour is to move from top to bottom, i.e. move to the cell beneath the cell being edited. Reimplement this function if you want different behaviour, e.g. moving from left to right.

[virtual]int Q3Table::addSelection(constQ3TableSelection & s)

Adds a selection described bys to the table and returns its number or -1 if the selection is invalid.

Remember to callQ3TableSelection::init() andQ3TableSelection::expandTo() to make the selection valid (see alsoQ3TableSelection::isActive(), or use theQ3TableSelection(int,int,int,int) constructor).

See alsonumSelections(),removeSelection(), andclearSelection().

[virtual slot]void Q3Table::adjustColumn(int col)

Resizes columncol so that the column width is wide enough to display the widest item the column contains.

See alsoadjustRow().

[virtual slot]void Q3Table::adjustRow(int row)

Resizes rowrow so that the row height is tall enough to display the tallest item the row contains.

See alsoadjustColumn().

[virtual protected]QWidget * Q3Table::beginEdit(int row,int col,bool replace)

This function is called to start in-place editing of the cell atrow,col. Editing is achieved by creating an editor (createEditor() is called) and setting the cell's editor withsetCellWidget() to the newly created editor. (After editing is completeendEdit() will be called to replace the cell's content with the editor's content.) Ifreplace is true the editor will start empty; otherwise it will be initialized with the cell's content (if any), i.e. the user will be modifying the original cell content.

See alsoendEdit().

[virtual]QRect Q3Table::cellGeometry(int row,int col) const

Returns the bounding rectangle of the cell atrow,col in content coordinates.

[virtual]QRect Q3Table::cellRect(int row,int col) const

Returns the geometry of cellrow,col in the cell's coordinate system. This is a convenience function useful inpaintCell(). It is equivalent toQRect(QPoint(0,0),cellGeometry( row, col).size());

See alsocellGeometry().

[virtual]QWidget * Q3Table::cellWidget(int row,int col) const

Returns the widget that has been set for the cell atrow,col, or 0 if no widget has been set.

If you don't useQ3TableItems you may need to reimplement this function: see the notes on large tables.

See alsoclearCellWidget() andsetCellWidget().

[virtual]void Q3Table::clearCell(int row,int col)

Removes theQ3TableItem atrow,col.

If you don't useQ3TableItems you may need to reimplement this function: see the notes on large tables.

[virtual]void Q3Table::clearCellWidget(int row,int col)

Removes the widget (if there is one) set for the cell atrow,col.

If you don't useQ3TableItems you may need to reimplement this function: see the notes on large tables.

This function deletes the widget atrow,col. Note that the widget is not deleted immediately; insteadQObject::deleteLater() is called on the widget to avoid problems with timing issues.

See alsocellWidget() andsetCellWidget().

[slot]void Q3Table::clearSelection(bool repaint = true)

Clears all selections and repaints the appropriate regions ifrepaint is true.

See alsoremoveSelection().

[signal]void Q3Table::clicked(int row,int col,int button, constQPoint & mousePos)

This signal is emitted when mouse buttonbutton is clicked. The cell where the event took place is atrow,col, and the mouse's position is inmousePos.

See alsoQt::MouseButton.

[virtual]int Q3Table::columnAt(int x) const

Returns the number of the column at positionx.x must be given in content coordinates.

See alsocolumnPos() androwAt().

[virtual protected slot]void Q3Table::columnClicked(int col)

This function is called when the columncol has been clicked. The default implementation sorts this column ifsorting() is true.

[virtual protected slot]void Q3Table::columnIndexChanged(int section,int fromIndex,int toIndex)

This function is called when column order is to be changed, i.e. when the user moved the column headersection fromfromIndex totoIndex.

If you want to change the column order programmatically, callswapRows() orswapColumns();

See alsoQ3Header::indexChange() androwIndexChanged().

[virtual]int Q3Table::columnPos(int col) const

Returns the x-coordinate of the columncol in content coordinates.

See alsocolumnAt() androwPos().

[virtual]int Q3Table::columnWidth(int col) const

Returns the width of columncol.

See alsosetColumnWidth() androwHeight().

[virtual protected slot]void Q3Table::columnWidthChanged(int col)

This function should be called whenever the column width ofcol has been changed. It updates the geometry of any affected columns and repaints the table to reflect the changes it has made.

[virtual protected]void Q3Table::contentsContextMenuEvent(QContextMenuEvent * e)

Reimplemented fromQ3ScrollView::contentsContextMenuEvent().

[virtual protected]void Q3Table::contentsDragEnterEvent(QDragEnterEvent * e)

Reimplemented fromQ3ScrollView::contentsDragEnterEvent().

This event handler is called whenever aQ3Table object receives aQDragEnterEvente, i.e. when the user pressed the mouse button to drag something.

The focus is moved to the cell where theQDragEnterEvent occurred.

[virtual protected]void Q3Table::contentsDragLeaveEvent(QDragLeaveEvent * e)

Reimplemented fromQ3ScrollView::contentsDragLeaveEvent().

This event handler is called when a drag activity leavesthisQ3Table object with evente.

[virtual protected]void Q3Table::contentsDragMoveEvent(QDragMoveEvent * e)

Reimplemented fromQ3ScrollView::contentsDragMoveEvent().

This event handler is called whenever aQ3Table object receives aQDragMoveEvente, i.e. when the user actually drags the mouse.

The focus is moved to the cell where theQDragMoveEvent occurred.

[virtual protected]void Q3Table::contentsDropEvent(QDropEvent * e)

Reimplemented fromQ3ScrollView::contentsDropEvent().

This event handler is called when the user ends a drag and drop by dropping something ontothisQ3Table and thus triggers the drop event,e.

[virtual protected]void Q3Table::contentsMouseDoubleClickEvent(QMouseEvent * e)

Reimplemented fromQ3ScrollView::contentsMouseDoubleClickEvent().

[virtual protected]void Q3Table::contentsMouseMoveEvent(QMouseEvent * e)

Reimplemented fromQ3ScrollView::contentsMouseMoveEvent().

[virtual protected]void Q3Table::contentsMousePressEvent(QMouseEvent * e)

Reimplemented fromQ3ScrollView::contentsMousePressEvent().

[virtual protected]void Q3Table::contentsMouseReleaseEvent(QMouseEvent * e)

Reimplemented fromQ3ScrollView::contentsMouseReleaseEvent().

[signal]void Q3Table::contextMenuRequested(int row,int col, constQPoint & pos)

This signal is emitted when the user invokes a context menu with the right mouse button (or with a system-specific keypress). The cell where the event took place is atrow,col.pos is the position where the context menu will appear in the global coordinate system. This signal is always emitted, even if the contents of the cell are disabled.

[virtual protected]QWidget * Q3Table::createEditor(int row,int col,bool initFromCell) const

This function returns the widget which should be used as an editor for the contents of the cell atrow,col.

IfinitFromCell is true, the editor is used to edit the current contents of the cell (so the editor widget should be initialized with this content). IfinitFromCell is false, the content of the cell is replaced with the new content which the user entered into the widget created by this function.

The default functionality is as follows: ifinitFromCell is true or the cell has aQ3TableItem and the table item'sQ3TableItem::isReplaceable() is false then the cell is asked to create an appropriate editor (usingQ3TableItem::createEditor()). Otherwise aQLineEdit is used as the editor.

If you want to create your own editor for certain cells, implement a customQ3TableItem subclass and reimplementQ3TableItem::createEditor().

If you are not usingQ3TableItems and you don't want to use aQLineEdit as the default editor, subclassQ3Table and reimplement this function with code like this:

Q3TableItem*i= item(row, col);if (initFromCell|| (i&&!i->isReplaceable()))// If we had a Q3TableItem ask the base class to create the editorreturnQ3Table::createEditor(row, col, initFromCell);elsereturn...(create your own editor)

Ownership of the editor widget is transferred to the caller.

If you reimplement this function return 0 for read-only cells. You will need to reimplementsetCellContentFromEditor() to retrieve the data the user entered.

See alsoQ3TableItem::createEditor().

[protected]int Q3Table::currEditCol() const

Returns the current edited column

[protected]int Q3Table::currEditRow() const

Returns the current edited row

[signal]void Q3Table::currentChanged(int row,int col)

This signal is emitted when the current cell has changed torow,col.

int Q3Table::currentColumn() const

Returns the current column.

See alsocurrentRow().

int Q3Table::currentRow() const

Returns the current row.

See alsocurrentColumn().

[virtual]int Q3Table::currentSelection() const

Returns the number of the current selection or -1 if there is no current selection.

See alsonumSelections().

[signal]void Q3Table::doubleClicked(int row,int col,int button, constQPoint & mousePos)

This signal is emitted when mouse buttonbutton is double-clicked. The cell where the event took place is atrow,col, and the mouse's position is inmousePos.

See alsoQt::MouseButton.

bool Q3Table::dragEnabled() const

If this function returns true, the table supports dragging.

See alsosetDragEnabled().

[virtual protected]Q3DragObject * Q3Table::dragObject()

If the user presses the mouse on a selected cell, starts moving (i.e. dragging), anddragEnabled() is true, this function is called to obtain a drag object. A drag using this object begins immediately unless dragObject() returns 0.

By default this function returns 0. You might reimplement it and create aQ3DragObject depending on the selected items.

See alsodropped().

[virtual protected]void Q3Table::drawContents(QPainter * p,int cx,int cy,int cw,int ch)

Reimplemented fromQ3ScrollView::drawContents().

Draws the table contents on the painterp. This function is optimized so that it only draws the cells inside thecw pixels wide andch pixels high clipping rectangle at positioncx,cy.

Additionally, drawContents() highlights the current cell.

[signal]void Q3Table::dropped(QDropEvent * e)

This signal is emitted when a drop event occurred on the table.

e contains information about the drop.

[virtual slot]void Q3Table::editCell(int row,int col,bool replace = false)

Starts editing the cell atrow,col.

Ifreplace is true the content of this cell will be replaced by the content of the editor when editing is finished, i.e. the user will be entering new data; otherwise the current content of the cell (if any) will be modified in the editor.

See alsobeginEdit().

[protected]EditMode Q3Table::editMode() const

Returns the current edit mode

See alsosetEditMode() andQ3Table::EditMode.

[virtual protected]void Q3Table::endEdit(int row,int col,bool accept,bool replace)

This function is called when in-place editing of the cell atrow,col is requested to stop.

If the cell is not being edited oraccept is false the function returns and the cell's contents are left unchanged.

Ifaccept is true the content of the editor must be transferred to the relevant cell. Ifreplace is true the current content of this cell should be replaced by the content of the editor (this means removing the currentQ3TableItem of the cell and creating a new one for the cell). Otherwise (if possible) the content of the editor should just be set to the existingQ3TableItem of this cell.

setCellContentFromEditor() is called to replace the contents of the cell with the contents of the cell's editor.

FinallyclearCellWidget() is called to remove the editor widget.

See alsosetCellContentFromEditor() andbeginEdit().

void Q3Table::ensureCellVisible(int row,int col)

Scrolls the table until the cell atrow,col becomes visible.

[virtual]bool Q3Table::eventFilter(QObject * o,QEvent * e)

Reimplemented fromQObject::eventFilter().

[virtual protected]void Q3Table::focusInEvent(QFocusEvent *)

Reimplemented fromQWidget::focusInEvent().

[virtual protected]void Q3Table::focusOutEvent(QFocusEvent * e)

Reimplemented fromQWidget::focusOutEvent().

[virtual slot]void Q3Table::hideColumn(int col)

Hides columncol.

See alsoshowColumn() andhideRow().

[virtual slot]void Q3Table::hideRow(int row)

Hides rowrow.

See alsoshowRow() andhideColumn().

Q3Header * Q3Table::horizontalHeader() const

Returns the table's topQ3Header.

This header contains the column labels.

To modify a column label useQ3Header::setLabel().

See alsoverticalHeader(),setTopMargin(), andQ3Header.

[protected]int Q3Table::indexOf(int row,int col) const

Returns a single integer which identifies a particularrow andcol by mapping the 2D table to a 1D array.

This is useful, for example, if you have a sparse table and want to use aQ3IntDict to map integers to the cells that are used.

[virtual]QVariant Q3Table::inputMethodQuery(Qt::InputMethodQuery query) const

Reimplemented fromQWidget::inputMethodQuery().

[virtual slot]void Q3Table::insertColumns(int col,int count = 1)

Insertscount empty columns at columncol. Also clears the selection(s).

See alsoinsertRows() andremoveColumn().

[virtual slot]void Q3Table::insertRows(int row,int count = 1)

Insertscount empty rows at rowrow. Also clears the selection(s).

See alsoinsertColumns() andremoveRow().

[virtual protected]void Q3Table::insertWidget(int row,int col,QWidget * w)

Inserts widgetw atrow,col into the internal data structure. See the documentation ofsetCellWidget() for further details.

If you don't useQ3TableItems you may need to reimplement this function: see the notes on large tables.

bool Q3Table::isColumnHidden(int col) const

Returns true if columncol is hidden; otherwise returns false.

See alsohideColumn() andisRowHidden().

bool Q3Table::isColumnReadOnly(int col) const

Returns true if columncol is read-only; otherwise returns false.

Whether a cell in this column is editable or read-only depends on the cell's EditType, and this setting.

See alsosetColumnReadOnly() andisRowReadOnly().

bool Q3Table::isColumnSelected(int col,bool full = false) const

Returns true if columncol is selected; otherwise returns false.

Iffull is false (the default), 'column is selected' means that at least one cell in the column is selected. Iffull is true, then 'column is selected' means every cell in the column is selected.

See alsoisRowSelected() andisSelected().

bool Q3Table::isColumnStretchable(int col) const

Returns true if columncol is stretchable; otherwise returns false.

See alsosetColumnStretchable() andisRowStretchable().

[protected]bool Q3Table::isEditing() const

Returns true if theEditMode isEditing orReplacing; otherwise (i.e. theEditMode isNotEditing) returns false.

See alsoQ3Table::EditMode.

bool Q3Table::isRowHidden(int row) const

Returns true if rowrow is hidden; otherwise returns false.

See alsohideRow() andisColumnHidden().

bool Q3Table::isRowReadOnly(int row) const

Returns true if rowrow is read-only; otherwise returns false.

Whether a cell in this row is editable or read-only depends on the cell'sEditType, and this setting.

See alsosetRowReadOnly() andisColumnReadOnly().

bool Q3Table::isRowSelected(int row,bool full = false) const

Returns true if rowrow is selected; otherwise returns false.

Iffull is false (the default), 'row is selected' means that at least one cell in the row is selected. Iffull is true, then 'row is selected' means every cell in the row is selected.

See alsoisColumnSelected() andisSelected().

bool Q3Table::isRowStretchable(int row) const

Returns true if rowrow is stretchable; otherwise returns false.

See alsosetRowStretchable() andisColumnStretchable().

bool Q3Table::isSelected(int row,int col) const

Returns true if the cell atrow,col is selected; otherwise returns false.

See alsoisRowSelected() andisColumnSelected().

[virtual]Q3TableItem * Q3Table::item(int row,int col) const

Returns theQ3TableItem representing the contents of the cell atrow,col.

Ifrow orcol are out of range or no content has been set for this cell, item() returns 0.

If you don't useQ3TableItems you may need to reimplement this function: see the notes on large tables.

See alsosetItem().

[virtual protected]void Q3Table::keyPressEvent(QKeyEvent * e)

Reimplemented fromQWidget::keyPressEvent().

[virtual]void Q3Table::paintCell(QPainter * p,int row,int col, constQRect & cr,bool selected, constQColorGroup & cg)

Paints the cell atrow,col on the painterp. The painter has already been translated to the cell's origin.cr describes the cell coordinates in the content coordinate system.

Ifselected is true the cell is highlighted.

cg is the colorgroup which should be used to draw the cell content.

If you want to draw custom cell content, for example right-aligned text, you must either reimplement paintCell(), or subclassQ3TableItem and reimplementQ3TableItem::paint() to do the custom drawing.

If you're using aQ3TableItem subclass, for example, to store a data structure, then reimplementingQ3TableItem::paint() may be the best approach. For data you want to draw immediately, e.g. data retrieved from a database, it is probably best to reimplement paintCell(). Note that if you reimplement paintCell(), i.e. don't useQ3TableItems, you must reimplement other functions: see the notes on large tables.

Note that the painter is not clipped by default in order to get maximum efficiency. If you want clipping, use code like this:

p->setClipRect(cellRect(row, col),QPainter::CoordPainter);//... your drawing codep->setClipping(false);

[virtual]void Q3Table::paintCell(QPainter * p,int row,int col, constQRect & cr,bool selected)

This is an overloaded function.

Use the otherpaintCell() function. This function is only included for backwards compatibility.

[virtual protected]void Q3Table::paintEmptyArea(QPainter * p,int cx,int cy,int cw,int ch)

This function fills thecw pixels wide andch pixels high rectangle starting at positioncx,cy with the background color using the painterp.

paintEmptyArea() is invoked bydrawContents() to erase or fill unused areas.

[virtual protected]void Q3Table::paintEvent(QPaintEvent * e)

Reimplemented fromQWidget::paintEvent().

[virtual]void Q3Table::paintFocus(QPainter * p, constQRect & cr)

Draws the focus rectangle of the current cell (seecurrentRow(),currentColumn()).

The painterp is already translated to the cell's origin, whilecr specifies the cell's geometry in content coordinates.

[virtual]QPixmap Q3Table::pixmap(int row,int col) const

Returns the pixmap set for the cell atrow,col, or a null-pixmap if the cell contains no pixmap.

See alsosetPixmap().

[signal]void Q3Table::pressed(int row,int col,int button, constQPoint & mousePos)

This signal is emitted when mouse buttonbutton is pressed. The cell where the event took place is atrow,col, and the mouse's position is inmousePos.

See alsoQt::MouseButton.

[virtual slot]void Q3Table::removeColumn(int col)

Removes columncol, and deletes all its cells including any table items and widgets the cells may contain. Also clears the selection(s).

See alsoremoveColumns(),hideColumn(),insertColumns(), andremoveRow().

[virtual slot]void Q3Table::removeColumns(constQ3MemArray<int> & cols)

Removes the columns listed in the arraycols, and deletes all their cells including any table items and widgets the cells may contain.

The array passed in must only contain valid columns (in the range from 0 tonumCols() - 1) with no duplicates, and must be sorted in ascending order. Also clears the selection(s).

See alsoremoveColumn(),insertColumns(), andremoveRows().

[virtual slot]void Q3Table::removeRow(int row)

Removes rowrow, and deletes all its cells including any table items and widgets the cells may contain. Also clears the selection(s).

See alsohideRow(),insertRows(),removeColumn(), andremoveRows().

[virtual slot]void Q3Table::removeRows(constQ3MemArray<int> & rows)

Removes the rows listed in the arrayrows, and deletes all their cells including any table items and widgets the cells may contain.

The array passed in must only contain valid rows (in the range from 0 tonumRows() - 1) with no duplicates, and must be sorted in ascending order. Also clears the selection(s).

See alsoremoveRow(),insertRows(), andremoveColumns().

[virtual]void Q3Table::removeSelection(constQ3TableSelection & s)

If the table has a selection,s, this selection is removed from the table.

See alsoaddSelection() andnumSelections().

[virtual]void Q3Table::removeSelection(int num)

This is an overloaded function.

Removes selection numbernum from the table.

See alsonumSelections(),addSelection(), andclearSelection().

void Q3Table::repaintSelections()

Repaints all selections

[virtual protected]void Q3Table::resizeData(int len)

This is called whenQ3Table's internal array needs to be resized tolen elements.

If you don't use Q3TableItems you should reimplement this as an empty method to avoid wasting memory. See the notes on large tables for further details.

[virtual]int Q3Table::rowAt(int y) const

Returns the number of the row at positiony.y must be given in content coordinates.

See alsorowPos() andcolumnAt().

[virtual]int Q3Table::rowHeight(int row) const

Returns the height of rowrow.

See alsosetRowHeight() andcolumnWidth().

[virtual protected slot]void Q3Table::rowHeightChanged(int row)

This function should be called whenever the row height ofrow has been changed. It updates the geometry of any affected rows and repaints the table to reflect the changes it has made.

[virtual protected slot]void Q3Table::rowIndexChanged(int section,int fromIndex,int toIndex)

This function is called when the order of the rows is to be changed, i.e. the user moved the row header sectionsection fromfromIndex totoIndex.

If you want to change the order programmatically, callswapRows() orswapColumns();

See alsoQ3Header::indexChange() andcolumnIndexChanged().

[virtual]int Q3Table::rowPos(int row) const

Returns the y-coordinate of the rowrow in content coordinates.

See alsorowAt() andcolumnPos().

void Q3Table::selectCells(int start_row,int start_col,int end_row,int end_col)

Selects the range starting atstart_row andstart_col and ending atend_row andend_col.

See alsoQ3TableSelection.

[virtual]void Q3Table::selectColumn(int col)

Selects the columncol.

See alsoQ3TableSelection.

[virtual]void Q3Table::selectRow(int row)

Selects the rowrow.

See alsoQ3TableSelection.

Q3TableSelection Q3Table::selection(int num) const

Returns selection numbernum, or an inactiveQ3TableSelection ifnum is out of range (seeQ3TableSelection::isActive()).

[signal]void Q3Table::selectionChanged()

This signal is emitted whenever a selection changes.

See alsoQ3TableSelection.

[virtual protected]void Q3Table::setCellContentFromEditor(int row,int col)

This function is called to replace the contents of the cell atrow,col with the contents of the cell's editor.

If there already exists aQ3TableItem for the cell, it callsQ3TableItem::setContentFromEditor() on thisQ3TableItem.

If, for example, you want to create differentQ3TableItems depending on the contents of the editor, you might reimplement this function.

If you want to work withoutQ3TableItems, you will need to reimplement this function to save the data the user entered into your data structure. (See the notes on large tables.)

See alsoQ3TableItem::setContentFromEditor() andcreateEditor().

[virtual]void Q3Table::setCellWidget(int row,int col,QWidget * e)

Sets the widgete to the cell atrow,col and takes care of placing and resizing the widget when the cell geometry changes.

By default widgets are inserted into a vector withnumRows() *numCols() elements. In very large tables you will probably want to store the widgets in a data structure that consumes less memory (see the notes on large tables). To support the use of your own data structure this function callsinsertWidget() to add the widget to the internal data structure. To use your own data structure reimplementinsertWidget(),cellWidget() andclearCellWidget().

Cell widgets are created dynamically with thenew operator. The cell widgets are destroyed automatically once the table is destroyed; the table takes ownership of the widget when using setCellWidget.

See alsocellWidget().

[slot]void Q3Table::setColumnLabels(constQStringList & labels)

Sets the section labels of thehorizontalHeader() tolabels

[virtual slot]void Q3Table::setColumnReadOnly(int col,bool ro)

Ifro is true, columncol is set to be read-only; otherwise the column is set to be editable.

Whether a cell in this column is editable or read-only depends on the cell's EditType, and this setting.

See alsoisColumnReadOnly(),setRowReadOnly(), andsetReadOnly().

[virtual slot]void Q3Table::setColumnStretchable(int col,bool stretch)

Ifstretch is true, columncol is set to be stretchable; otherwise columncol is set to be unstretchable.

If the table widget's width decreases or increases stretchable columns will grow narrower or wider to fit the space available as completely as possible. The user cannot manually resize stretchable columns.

See alsoisColumnStretchable(),setRowStretchable(), andadjustColumn().

[virtual slot]void Q3Table::setColumnWidth(int col,int w)

Resizes columncol to bew pixels wide.

See alsocolumnWidth() andsetRowHeight().

[virtual slot]void Q3Table::setCurrentCell(int row,int col)

Moves the focus to the cell atrow,col.

See alsocurrentRow() andcurrentColumn().

[virtual slot]void Q3Table::setDragEnabled(bool b)

Ifb is true, the table starts a drag (seedragObject()) when the user presses and moves the mouse on a selected cell.

See alsodragEnabled().

[protected]void Q3Table::setEditMode(EditMode mode,int row,int col)

Sets the current edit mode tomode, the current edit row torow and the current edit column tocol.

See alsoeditMode() andEditMode.

[virtual]void Q3Table::setItem(int row,int col,Q3TableItem * item)

Inserts the table itemitem into the table at rowrow, columncol, and repaints the cell. If a table item already exists in this cell it is deleted and replaced withitem. The table takes ownership of the table item.

If you don't useQ3TableItems you may need to reimplement this function: see the notes on large tables.

See alsoitem() andtakeItem().

[virtual slot]void Q3Table::setLeftMargin(int m)

Sets the left margin to bem pixels wide.

TheverticalHeader(), which displays row labels, occupies this margin.

In an Arabic or Hebrew localization, theverticalHeader() will appear on the right side of the table, and this call will set the right margin.

See alsoleftMargin(),setTopMargin(), andverticalHeader().

[virtual]void Q3Table::setPixmap(int row,int col, constQPixmap & pix)

Sets the pixmap in the cell atrow,col topix.

If the cell does not contain a table item aQ3TableItem is created with anEditType ofOnTyping, otherwise the existing table item's pixmap (if any) is replaced withpix.

Note thatQ3ComboTableItems andQ3CheckTableItems don't show pixmaps.

See alsopixmap(),setText(),setItem(), andQ3TableItem::setPixmap().

[virtual slot]void Q3Table::setRowHeight(int row,int h)

Resizes rowrow to beh pixels high.

See alsorowHeight() andsetColumnWidth().

[slot]void Q3Table::setRowLabels(constQStringList & labels)

Sets the section labels of theverticalHeader() tolabels

[virtual slot]void Q3Table::setRowReadOnly(int row,bool ro)

Ifro is true, rowrow is set to be read-only; otherwise the row is set to be editable.

Whether a cell in this row is editable or read-only depends on the cell's EditType, and this setting.

See alsoisRowReadOnly(),setColumnReadOnly(), andsetReadOnly().

[virtual slot]void Q3Table::setRowStretchable(int row,bool stretch)

Ifstretch is true, rowrow is set to be stretchable; otherwise rowrow is set to be unstretchable.

If the table widget's height decreases or increases stretchable rows will grow shorter or taller to fit the space available as completely as possible. The user cannot manually resize stretchable rows.

See alsoisRowStretchable() andsetColumnStretchable().

[virtual]void Q3Table::setText(int row,int col, constQString & text)

Sets the text in the cell atrow,col totext.

If the cell does not contain a table item aQ3TableItem is created with anEditType ofOnTyping, otherwise the existing table item's text (if any) is replaced withtext.

See alsotext(),setPixmap(),setItem(), andQ3TableItem::setText().

[virtual slot]void Q3Table::setTopMargin(int m)

Sets the top margin to bem pixels high.

ThehorizontalHeader(), which displays column labels, occupies this margin.

See alsotopMargin() andsetLeftMargin().

[virtual slot]void Q3Table::showColumn(int col)

Shows columncol.

See alsohideColumn() andshowRow().

[virtual protected]void Q3Table::showEvent(QShowEvent * e)

Reimplemented fromQWidget::showEvent().

[virtual slot]void Q3Table::showRow(int row)

Shows rowrow.

See alsohideRow() andshowColumn().

[virtual]QSize Q3Table::sizeHint() const

Reimplemented fromQWidget::sizeHint().

[virtual]void Q3Table::sortColumn(int col,bool ascending = true,bool wholeRows = false)

Sorts columncol. Ifascending is true the sort is in ascending order, otherwise the sort is in descending order.

IfwholeRows is true, entire rows are sorted usingswapRows(); otherwise only cells in the column are sorted usingswapCells().

Note that if you are not using Q3TableItems you will need to reimplementswapRows() andswapCells(). (See the notes on large tables.)

See alsoswapRows().

[virtual protected]void Q3Table::startDrag()

Starts a drag.

Usually you don't need to call or reimplement this function yourself.

See alsodragObject().

[virtual slot]void Q3Table::swapCells(int row1,int col1,int row2,int col2)

Swaps the contents of the cell atrow1,col1 with the contents of the cell atrow2,col2.

This function is also called when the table is sorted.

If you don't useQ3TableItems and want your users to be able to swap cells, you will need to reimplement this function. (See the notes on large tables.)

See alsoswapColumns() andswapRows().

[virtual slot]void Q3Table::swapColumns(int col1,int col2,bool swapHeader = false)

Swaps the data incol1 withcol2.

This function is used to swap the positions of two columns. It is called when the user changes the order of columns (seesetColumnMovingEnabled(), and when columns are sorted.

If you don't useQ3TableItems and want your users to be able to swap columns you will need to reimplement this function. (See the notes on large tables.)

IfswapHeader is true, the columns' header contents is also swapped.

See alsoswapCells().

[virtual slot]void Q3Table::swapRows(int row1,int row2,bool swapHeader = false)

Swaps the data inrow1 androw2.

This function is used to swap the positions of two rows. It is called when the user changes the order of rows (seesetRowMovingEnabled()), and when rows are sorted.

If you don't useQ3TableItems and want your users to be able to swap rows, e.g. for sorting, you will need to reimplement this function. (See the notes on large tables.)

IfswapHeader is true, the rows' header contents is also swapped.

This function will not update theQ3Table, you will have to do this manually, e.g. by callingupdateContents().

See alsoswapColumns() andswapCells().

[virtual]void Q3Table::takeItem(Q3TableItem * i)

Takes the table itemi out of the table. This function doesnot delete the table item. You must either delete the table item yourself or put it into a table (usingsetItem()) which will then take ownership of it.

Use this function if you want to move an item from one cell in a table to another, or to move an item from one table to another, reinserting the item withsetItem().

If you want to exchange two cells useswapCells().

[virtual]QString Q3Table::text(int row,int col) const

Returns the text in the cell atrow,col, or an empty string if the relevant item does not exist or has no text.

See alsosetText() andsetPixmap().

void Q3Table::updateCell(int row,int col)

Repaints the cell atrow,col.

void Q3Table::updateHeaderStates()

This functions updates all the header states to be in sync with the current selections. This should be called after programmatically changing, adding or removing selections, so that the headers are updated.

[signal]void Q3Table::valueChanged(int row,int col)

This signal is emitted when the user changed the value in the cell atrow,col.

Q3Header * Q3Table::verticalHeader() const

Returns the table's verticalQ3Header.

This header contains the row labels.

See alsohorizontalHeader(),setLeftMargin(), andQ3Header.

[virtual protected]void Q3Table::viewportResizeEvent(QResizeEvent * e)

Reimplemented fromQ3ScrollView::viewportResizeEvent().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp