Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QTableSelection Class Reference

The QTableSelection class provides access to a selected area in a QTable. More...

    #include <QTableSelection>

This class is part of the Qt 3 compatibility library. It is provided to keep old source code working. We strongly advise against using it in new code.

- List of all members, including inherited members

### Public Functions

- QTableSelection ()
- QTableSelection ( int start_row, int start_col, int end_row, int end_col )
- int anchorCol () const
- int anchorRow () const
- int bottomRow () const
- void expandTo ( int row, int col )
- void init ( int row, int col )
- bool isActive () const
- bool isEmpty () const
- int leftCol () const
- int numCols () const
- int numRows () const
- int rightCol () const
- int topRow () const
- bool operator!= ( const QTableSelection & s ) const
- bool operator== ( const QTableSelection & s ) const

## Detailed Description

The QTableSelection class provides access to a selected area in a QTable.

The selection is a rectangular set of cells in a QTable. One of the rectangle's cells is called the anchor cell; this is the cell that was selected first.

The easiest way to create a selection is to use QTable::selectCells() or QTable::selectRow() or QTable::selectColumn(). If you want to create a selection that you can resize later, then use this class instead. The simplest way to create a selection with this class is to use the constructor that takes a start row and column (this becomes the anchor cell) and an end row and column. Alternatively, use the no-argument constructor, then call init() to set the anchor cell and then call expandTo() to set the end row and column.

There are various access functions to find out about the area: anchorRow() and anchorCol() return the anchor's position; leftCol(), rightCol(), topRow() and bottomRow() return the rectangle's four edges. All four are part of the selection.

QTable::selectCells() QTable::selectRow() QTable::selectColumn()

See also QTable, QTable::addSelection(), and QTable::selection().

## Member Function Documentation

### QTableSelection::QTableSelection ()

Creates an inactive selection. Use init() and expandTo() to activate it.

### QTableSelection::QTableSelection ( int start_row, int start_col, int end_row, int end_col )

Creates an active selection, starting at start_row and start_col, (which becomes the anchor cell) and ending at end_row and end_col.

### int QTableSelection::anchorCol () const

Returns the anchor column of the selection.

See also anchorRow() and expandTo().

### int QTableSelection::anchorRow () const

Returns the anchor row of the selection.

See also anchorCol() and expandTo().

### int QTableSelection::bottomRow () const

Returns the bottom row of the selection.

See also topRow(), leftCol(), and rightCol().

### void QTableSelection::expandTo ( int row, int col )

Expands the selection to include cell row, col. The new selection rectangle is the bounding rectangle of row, col and the previous selection rectangle. After calling this function the selection is active.

If you haven't called init() (or the four-argument constructor), this function does nothing.

See also init() and isActive().

### void QTableSelection::init ( int row, int col )

Sets the selection anchor to cell row, col and the selection to only contain this cell. The selection is not active until expandTo() is called.

To extend the selection to include additional cells, call expandTo().

See also isActive().

### bool QTableSelection::isActive () const

Returns whether the selection is active or not. A selection is active after init() and expandTo() have been called (or if the four-argument constructor is used).

### bool QTableSelection::isEmpty () const

Returns whether true if the selection is empty; otherwise returns false.

See also numRows() and numCols().

### int QTableSelection::leftCol () const

Returns the left column of the selection.

See also topRow(), bottomRow(), and rightCol().

### int QTableSelection::numCols () const

Returns the number of columns in the selection.

See also numRows().

### int QTableSelection::numRows () const

Returns the number of rows in the selection.

See also numCols().

### int QTableSelection::rightCol () const

Returns the right column of the selection.

See also topRow(), bottomRow(), and leftCol().

### int QTableSelection::topRow () const

Returns the top row of the selection.

See also bottomRow(), leftCol(), and rightCol().

### bool QTableSelection::operator!= ( const QTableSelection & s ) const

Returns true if s does not include the same cells as the selection; otherwise returns false.

### bool QTableSelection::operator== ( const QTableSelection & s ) const

Returns true if s includes the same cells as the selection; otherwise returns false.