summaryrefslogtreecommitdiffstats
path: root/doc/html/qgridview.html
blob: c052dd4dc64344ee9860af8b11eace89666d4273 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qgridview.cpp:45 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QGridView Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QGridView Class Reference</h1>

<p>The QGridView class provides an abstract base for
fixed-size grids.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qgridview-h.html">qgridview.h</a>&gt;</tt>
<p>Inherits <a href="qscrollview.html">QScrollView</a>.
<p><a href="qgridview-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QGridView"><b>QGridView</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )</li>
<li class=fn><a href="#~QGridView"><b>~QGridView</b></a> ()</li>
<li class=fn>int <a href="#numRows"><b>numRows</b></a> () const</li>
<li class=fn>virtual void <a href="#setNumRows"><b>setNumRows</b></a> ( int )</li>
<li class=fn>int <a href="#numCols"><b>numCols</b></a> () const</li>
<li class=fn>virtual void <a href="#setNumCols"><b>setNumCols</b></a> ( int )</li>
<li class=fn>int <a href="#cellWidth"><b>cellWidth</b></a> () const</li>
<li class=fn>virtual void <a href="#setCellWidth"><b>setCellWidth</b></a> ( int )</li>
<li class=fn>int <a href="#cellHeight"><b>cellHeight</b></a> () const</li>
<li class=fn>virtual void <a href="#setCellHeight"><b>setCellHeight</b></a> ( int )</li>
<li class=fn>QRect <a href="#cellRect"><b>cellRect</b></a> () const</li>
<li class=fn>QRect <a href="#cellGeometry"><b>cellGeometry</b></a> ( int&nbsp;row, int&nbsp;column )</li>
<li class=fn>QSize <a href="#gridSize"><b>gridSize</b></a> () const</li>
<li class=fn>int <a href="#rowAt"><b>rowAt</b></a> ( int&nbsp;y ) const</li>
<li class=fn>int <a href="#columnAt"><b>columnAt</b></a> ( int&nbsp;x ) const</li>
<li class=fn>void <a href="#repaintCell"><b>repaintCell</b></a> ( int&nbsp;row, int&nbsp;column, bool&nbsp;erase = TRUE )</li>
<li class=fn>void <a href="#updateCell"><b>updateCell</b></a> ( int&nbsp;row, int&nbsp;column )</li>
<li class=fn>void <a href="#ensureCellVisible"><b>ensureCellVisible</b></a> ( int&nbsp;row, int&nbsp;column )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>int <a href="#cellHeight-prop"><b>cellHeight</b></a>&nbsp;- the height of a grid row</li>
<li class=fn>int <a href="#cellWidth-prop"><b>cellWidth</b></a>&nbsp;- the width of a grid column</li>
<li class=fn>int <a href="#numCols-prop"><b>numCols</b></a>&nbsp;- the number of columns in the grid</li>
<li class=fn>int <a href="#numRows-prop"><b>numRows</b></a>&nbsp;- the number of rows in the grid</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#paintCell"><b>paintCell</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col ) = 0</li>
<li class=fn>virtual void <a href="#paintEmptyArea"><b>paintEmptyArea</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )</li>
<li class=fn>virtual void <a href="#dimensionChange"><b>dimensionChange</b></a> ( int&nbsp;oldNumRows, int&nbsp;oldNumCols )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QGridView class provides an abstract base for
fixed-size grids.
<p> 
<p> 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 <a href="#numRows">numRows</a>()-1, column
<a href="#numCols">numCols</a>()-1.
<p> You can define <a href="#numRows-prop">numRows</a>, <a href="#numCols-prop">numCols</a>, <a href="#cellWidth-prop">cellWidth</a> and <a href="#cellHeight-prop">cellHeight</a>. Reimplement the pure virtual function <a href="#paintCell">paintCell</a>() to
draw the contents of a cell.
<p> With <a href="#ensureCellVisible">ensureCellVisible</a>(), you can ensure a certain cell is
visible. With <a href="#rowAt">rowAt</a>() and <a href="#columnAt">columnAt</a>() you can find a cell based on
the given x- and y-coordinates.
<p> If you need to monitor changes to the grid's dimensions (i.e. when
numRows or numCols is changed), reimplement the <a href="#dimensionChange">dimensionChange</a>()
change handler.
<p> 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).
<p> QGridView is a very simple abstract class based on <a href="qscrollview.html">QScrollView</a>. 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 <a href="qtable.html">QTable</a> instead. If you need a
simple list of items, use a <a href="qlistbox.html">QListBox</a>. If you need to present
hierachical data use a <a href="qlistview.html">QListView</a>, and if you need random objects
at random positions, consider using either a <a href="qiconview.html">QIconView</a> or a
<a href="qcanvas.html">QCanvas</a>.
<p>See also <a href="abstractwidgets.html">Abstract Widget Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QGridView"></a>QGridView::QGridView ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )
</h3>
Constructs a grid view.
<p> The <em>parent</em>, <em>name</em> and <a href="qt.html#WidgetFlags">widget flag</a>, <em>f</em>, arguments are passed
to the <a href="qscrollview.html">QScrollView</a> constructor.

<h3 class=fn><a name="~QGridView"></a>QGridView::~QGridView ()
</h3>
Destroys the grid view.

<h3 class=fn><a href="qrect.html">QRect</a> <a name="cellGeometry"></a>QGridView::cellGeometry ( int&nbsp;row, int&nbsp;column )
</h3>
Returns the geometry of cell (<em>row</em>, <em>column</em>) in the content
coordinate system.
<p> <p>See also <a href="#cellRect">cellRect</a>().

<h3 class=fn>int <a name="cellHeight"></a>QGridView::cellHeight () const
</h3><p>Returns the height of a grid row.
See the <a href="qgridview.html#cellHeight-prop">"cellHeight"</a> property for details.
<h3 class=fn><a href="qrect.html">QRect</a> <a name="cellRect"></a>QGridView::cellRect () const
</h3>

<p> Returns the geometry of a cell in a cell's coordinate system. This
is a convenience function useful in <a href="#paintCell">paintCell</a>(). It is equivalent
to <a href="qrect.html">QRect</a>( 0, 0, <a href="#cellWidth">cellWidth</a>(), <a href="#cellHeight">cellHeight</a>() ).
<p> <p>See also <a href="#cellGeometry">cellGeometry</a>().

<p> 
<h3 class=fn>int <a name="cellWidth"></a>QGridView::cellWidth () const
</h3><p>Returns the width of a grid column.
See the <a href="qgridview.html#cellWidth-prop">"cellWidth"</a> property for details.
<h3 class=fn>int <a name="columnAt"></a>QGridView::columnAt ( int&nbsp;x ) const
</h3>

<p> Returns the number of the column at position <em>x</em>. <em>x</em> must be
given in content coordinates.
<p> <p>See also <a href="#rowAt">rowAt</a>().

<h3 class=fn>void <a name="dimensionChange"></a>QGridView::dimensionChange ( int&nbsp;oldNumRows, int&nbsp;oldNumCols )<tt> [virtual protected]</tt>
</h3>

<p> This change handler is called whenever any of the grid's
dimensions change. <em>oldNumRows</em> and <em>oldNumCols</em> contain the
old dimensions, <a href="#numRows">numRows</a>() and <a href="#numCols">numCols</a>() contain the new
dimensions.

<h3 class=fn>void <a name="ensureCellVisible"></a>QGridView::ensureCellVisible ( int&nbsp;row, int&nbsp;column )
</h3>
Ensures cell (<em>row</em>, <em>column</em>) is visible, scrolling the grid
view if necessary.

<h3 class=fn><a href="qsize.html">QSize</a> <a name="gridSize"></a>QGridView::gridSize () const
</h3>

<p> Returns the size of the grid in pixels.
<p> 
<h3 class=fn>int <a name="numCols"></a>QGridView::numCols () const
</h3><p>Returns the number of columns in the grid.
See the <a href="qgridview.html#numCols-prop">"numCols"</a> property for details.
<h3 class=fn>int <a name="numRows"></a>QGridView::numRows () const
</h3><p>Returns the number of rows in the grid.
See the <a href="qgridview.html#numRows-prop">"numRows"</a> property for details.
<h3 class=fn>void <a name="paintCell"></a>QGridView::paintCell ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col )<tt> [pure virtual protected]</tt>
</h3>

<p> This pure virtual function is called to paint the single cell at
(<em>row</em>, <em>col</em>) using painter <em>p</em>. The painter must be open when
<a href="#paintCell">paintCell</a>() is called and must remain open.
<p> The coordinate system is <a href="qpainter.html#translate">translated</a> so that the origin is at the top-left corner of the cell
to be painted, i.e. <em>cell</em> coordinates. Do not scale or shear
the coordinate system (or if you do, restore the <a href="qwmatrix.html#TransformationMode">transformation matrix</a> before you return).
<p> The painter is not clipped by default in order to get maximum
efficiency. If you want clipping, use
<p> <pre>
    p-&gt;setClipRect( <a href="#cellRect">cellRect</a>(), QPainter::CoordPainter );
    //... your drawing code
    p-&gt;setClipping( FALSE );

    </pre>
 

<h3 class=fn>void <a name="paintEmptyArea"></a>QGridView::paintEmptyArea ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )<tt> [virtual protected]</tt>
</h3>
This function fills the <em>cw</em> pixels wide and <em>ch</em> pixels high
rectangle starting at position (<em>cx</em>, <em>cy</em>) with the background
color using the painter <em>p</em>.
<p> <a href="#paintEmptyArea">paintEmptyArea</a>() is invoked by <a href="qscrollview.html#drawContents">drawContents</a>() to erase or fill
unused areas.

<h3 class=fn>void <a name="repaintCell"></a>QGridView::repaintCell ( int&nbsp;row, int&nbsp;column, bool&nbsp;erase = TRUE )
</h3>
Repaints cell (<em>row</em>, <em>column</em>).
<p> If <em>erase</em> is TRUE, Qt erases the area of the cell before the
<a href="#paintCell">paintCell</a>() call; otherwise no erasing takes place.
<p> <p>See also <a href="qwidget.html#repaint">QWidget::repaint</a>().

<h3 class=fn>int <a name="rowAt"></a>QGridView::rowAt ( int&nbsp;y ) const
</h3>

<p> Returns the number of the row at position <em>y</em>. <em>y</em> must be given
in content coordinates.
<p> <p>See also <a href="#columnAt">columnAt</a>().

<h3 class=fn>void <a name="setCellHeight"></a>QGridView::setCellHeight ( int )<tt> [virtual]</tt>
</h3><p>Sets the height of a grid row.
See the <a href="qgridview.html#cellHeight-prop">"cellHeight"</a> property for details.
<h3 class=fn>void <a name="setCellWidth"></a>QGridView::setCellWidth ( int )<tt> [virtual]</tt>
</h3><p>Sets the width of a grid column.
See the <a href="qgridview.html#cellWidth-prop">"cellWidth"</a> property for details.
<h3 class=fn>void <a name="setNumCols"></a>QGridView::setNumCols ( int )<tt> [virtual]</tt>
</h3><p>Sets the number of columns in the grid.
See the <a href="qgridview.html#numCols-prop">"numCols"</a> property for details.
<h3 class=fn>void <a name="setNumRows"></a>QGridView::setNumRows ( int )<tt> [virtual]</tt>
</h3><p>Sets the number of rows in the grid.
See the <a href="qgridview.html#numRows-prop">"numRows"</a> property for details.
<h3 class=fn>void <a name="updateCell"></a>QGridView::updateCell ( int&nbsp;row, int&nbsp;column )
</h3>
Updates cell (<em>row</em>, <em>column</em>).
<p> <p>See also <a href="qwidget.html#update">QWidget::update</a>().

<hr><h2>Property Documentation</h2>
<h3 class=fn>int <a name="cellHeight-prop"></a>cellHeight</h3>
<p>This property holds the height of a grid row.
<p>All rows in a grid view have the same height.
<p> <p>See also <a href="#cellWidth-prop">cellWidth</a>.

<p>Set this property's value with <a href="#setCellHeight">setCellHeight</a>() and get this property's value with <a href="#cellHeight">cellHeight</a>().
<h3 class=fn>int <a name="cellWidth-prop"></a>cellWidth</h3>
<p>This property holds the width of a grid column.
<p>All columns in a grid view have the same width.
<p> <p>See also <a href="#cellHeight-prop">cellHeight</a>.

<p>Set this property's value with <a href="#setCellWidth">setCellWidth</a>() and get this property's value with <a href="#cellWidth">cellWidth</a>().
<h3 class=fn>int <a name="numCols-prop"></a>numCols</h3>
<p>This property holds the number of columns in the grid.
<p>Set this property's value with <a href="#setNumCols">setNumCols</a>() and get this property's value with <a href="#numCols">numCols</a>().
<p><p>See also <a href="#numRows-prop">numRows</a>.

<h3 class=fn>int <a name="numRows-prop"></a>numRows</h3>
<p>This property holds the number of rows in the grid.
<p>Set this property's value with <a href="#setNumRows">setNumRows</a>() and get this property's value with <a href="#numRows">numRows</a>().
<p><p>See also <a href="#numCols-prop">numCols</a>.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>