You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/man/man3/qgridview.3qt

246 lines
9.4 KiB

'\" t
.TH QGridView 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QGridView \- Abstract base for fixed-size grids
.SH SYNOPSIS
\fC#include <qgridview.h>\fR
.PP
Inherits QScrollView.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQGridView\fR ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
.br
.ti -1c
.BI "\fB~QGridView\fR ()"
.br
.ti -1c
.BI "int \fBnumRows\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetNumRows\fR ( int )"
.br
.ti -1c
.BI "int \fBnumCols\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetNumCols\fR ( int )"
.br
.ti -1c
.BI "int \fBcellWidth\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetCellWidth\fR ( int )"
.br
.ti -1c
.BI "int \fBcellHeight\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetCellHeight\fR ( int )"
.br
.ti -1c
.BI "QRect \fBcellRect\fR () const"
.br
.ti -1c
.BI "QRect \fBcellGeometry\fR ( int row, int column )"
.br
.ti -1c
.BI "QSize \fBgridSize\fR () const"
.br
.ti -1c
.BI "int \fBrowAt\fR ( int y ) const"
.br
.ti -1c
.BI "int \fBcolumnAt\fR ( int x ) const"
.br
.ti -1c
.BI "void \fBrepaintCell\fR ( int row, int column, bool erase = TRUE )"
.br
.ti -1c
.BI "void \fBupdateCell\fR ( int row, int column )"
.br
.ti -1c
.BI "void \fBensureCellVisible\fR ( int row, int column )"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "int \fBcellHeight\fR - the height of a grid row"
.br
.ti -1c
.BI "int \fBcellWidth\fR - the width of a grid column"
.br
.ti -1c
.BI "int \fBnumCols\fR - the number of columns in the grid"
.br
.ti -1c
.BI "int \fBnumRows\fR - the number of rows in the grid"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual void \fBpaintCell\fR ( QPainter * p, int row, int col ) = 0"
.br
.ti -1c
.BI "virtual void \fBpaintEmptyArea\fR ( QPainter * p, int cx, int cy, int cw, int ch )"
.br
.ti -1c
.BI "virtual void \fBdimensionChange\fR ( int oldNumRows, int oldNumCols )"
.br
.in -1c
.SH DESCRIPTION
The QGridView class provides an abstract base for fixed-size grids.
.PP
A grid view consists of a number of abstract cells organized in rows and columns. The cells have a fixed size and are identified with a row index and a column index. The top-left cell is in row 0, column 0. The bottom-right cell is in row numRows()-1, column numCols()-1.
.PP
You can define numRows, numCols, cellWidth and cellHeight. Reimplement the pure virtual function paintCell() to draw the contents of a cell.
.PP
With ensureCellVisible(), you can ensure a certain cell is visible. With rowAt() and columnAt() you can find a cell based on the given x- and y-coordinates.
.PP
If you need to monitor changes to the grid's dimensions (i.e. when numRows or numCols is changed), reimplement the dimensionChange() change handler.
.PP
Note: the row and column indices are always given in the order, row (vertical offset) then column (horizontal offset). This order is the opposite of all pixel operations, which are given in the order x (horizontal offset), y (vertical offset).
.PP
QGridView is a very simple abstract class based on QScrollView. It is designed to simplify the task of drawing many cells of the same size in a potentially scrollable canvas. If you need rows and columns with different sizes, use a QTable instead. If you need a simple list of items, use a QListBox. If you need to present hierachical data use a QListView, and if you need random objects at random positions, consider using either a QIconView or a QCanvas.
.PP
See also Abstract Widget Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QGridView::QGridView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
Constructs a grid view.
.PP
The \fIparent\fR, \fIname\fR and widget flag, \fIf\fR, arguments are passed to the QScrollView constructor.
.SH "QGridView::~QGridView ()"
Destroys the grid view.
.SH "QRect QGridView::cellGeometry ( int row, int column )"
Returns the geometry of cell (\fIrow\fR, \fIcolumn\fR) in the content coordinate system.
.PP
See also cellRect().
.SH "int QGridView::cellHeight () const"
Returns the height of a grid row. See the "cellHeight" property for details.
.SH "QRect QGridView::cellRect () const"
Returns the geometry of a cell in a cell's coordinate system. This is a convenience function useful in paintCell(). It is equivalent to QRect( 0, 0, cellWidth(), cellHeight() ).
.PP
See also cellGeometry().
.SH "int QGridView::cellWidth () const"
Returns the width of a grid column. See the "cellWidth" property for details.
.SH "int QGridView::columnAt ( int x ) const"
Returns the number of the column at position \fIx\fR. \fIx\fR must be given in content coordinates.
.PP
See also rowAt().
.SH "void QGridView::dimensionChange ( int oldNumRows, int oldNumCols )\fC [virtual protected]\fR"
This change handler is called whenever any of the grid's dimensions change. \fIoldNumRows\fR and \fIoldNumCols\fR contain the old dimensions, numRows() and numCols() contain the new dimensions.
.SH "void QGridView::ensureCellVisible ( int row, int column )"
Ensures cell (\fIrow\fR, \fIcolumn\fR) is visible, scrolling the grid view if necessary.
.SH "QSize QGridView::gridSize () const"
Returns the size of the grid in pixels.
.SH "int QGridView::numCols () const"
Returns the number of columns in the grid. See the "numCols" property for details.
.SH "int QGridView::numRows () const"
Returns the number of rows in the grid. See the "numRows" property for details.
.SH "void QGridView::paintCell ( QPainter * p, int row, int col )\fC [pure virtual protected]\fR"
This pure virtual function is called to paint the single cell at (\fIrow\fR, \fIcol\fR) using painter \fIp\fR. The painter must be open when paintCell() is called and must remain open.
.PP
The coordinate system is translated so that the origin is at the top-left corner of the cell to be painted, i.e. \fIcell\fR coordinates. Do not scale or shear the coordinate system (or if you do, restore the transformation matrix before you return).
.PP
The painter is not clipped by default in order to get maximum efficiency. If you want clipping, use
.PP
.nf
.br
p->setClipRect( cellRect(), QPainter::CoordPainter );
.br
//... your drawing code
.br
p->setClipping( FALSE );
.br
.br
.fi
.SH "void QGridView::paintEmptyArea ( QPainter * p, int cx, int cy, int cw, int ch )\fC [virtual protected]\fR"
This function fills the \fIcw\fR pixels wide and \fIch\fR pixels high rectangle starting at position (\fIcx\fR, \fIcy\fR) with the background color using the painter \fIp\fR.
.PP
paintEmptyArea() is invoked by drawContents() to erase or fill unused areas.
.SH "void QGridView::repaintCell ( int row, int column, bool erase = TRUE )"
Repaints cell (\fIrow\fR, \fIcolumn\fR).
.PP
If \fIerase\fR is TRUE, Qt erases the area of the cell before the paintCell() call; otherwise no erasing takes place.
.PP
See also QWidget::repaint().
.SH "int QGridView::rowAt ( int y ) const"
Returns the number of the row at position \fIy\fR. \fIy\fR must be given in content coordinates.
.PP
See also columnAt().
.SH "void QGridView::setCellHeight ( int )\fC [virtual]\fR"
Sets the height of a grid row. See the "cellHeight" property for details.
.SH "void QGridView::setCellWidth ( int )\fC [virtual]\fR"
Sets the width of a grid column. See the "cellWidth" property for details.
.SH "void QGridView::setNumCols ( int )\fC [virtual]\fR"
Sets the number of columns in the grid. See the "numCols" property for details.
.SH "void QGridView::setNumRows ( int )\fC [virtual]\fR"
Sets the number of rows in the grid. See the "numRows" property for details.
.SH "void QGridView::updateCell ( int row, int column )"
Updates cell (\fIrow\fR, \fIcolumn\fR).
.PP
See also QWidget::update().
.SS "Property Documentation"
.SH "int cellHeight"
This property holds the height of a grid row.
.PP
All rows in a grid view have the same height.
.PP
See also cellWidth.
.PP
Set this property's value with setCellHeight() and get this property's value with cellHeight().
.SH "int cellWidth"
This property holds the width of a grid column.
.PP
All columns in a grid view have the same width.
.PP
See also cellHeight.
.PP
Set this property's value with setCellWidth() and get this property's value with cellWidth().
.SH "int numCols"
This property holds the number of columns in the grid.
.PP
Set this property's value with setNumCols() and get this property's value with numCols().
.PP
See also numRows.
.SH "int numRows"
This property holds the number of rows in the grid.
.PP
Set this property's value with setNumRows() and get this property's value with numRows().
.PP
See also numCols.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/qgridview.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qgridview.3qt) and the Qt
version (3.3.8).