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

  • Qt 4.8
  • Qt3SupportLight
  • Q3GridView

Q3GridView Class

TheQ3GridView class provides an abstract base for fixed-size grids.More...

Header:#include <Q3GridView>
Inherits:Q3ScrollView

Properties

Public Functions

Q3GridView(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0)
~Q3GridView()
QRectcellGeometry(int row, int column)
intcellHeight() const
QRectcellRect() const
intcellWidth() const
intcolumnAt(int x) const
voidensureCellVisible(int row, int column)
QSizegridSize() const
intnumCols() const
intnumRows() const
voidrepaintCell(int row, int column, bool erase = true)
introwAt(int y) const
virtual voidsetCellHeight(int)
virtual voidsetCellWidth(int)
virtual voidsetNumCols(int)
virtual voidsetNumRows(int)
voidupdateCell(int row, int column)
  • 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

Protected Functions

virtual voiddimensionChange(int oldNumRows, int oldNumCols)
virtual voidpaintCell(QPainter * p, int row, int col) = 0
virtual voidpaintEmptyArea(QPainter * p, int cx, int cy, int cw, int ch)

Reimplemented Protected Functions

virtual voiddrawContents(QPainter * p, int cx, int cy, int cw, int ch)
  • 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

Additional Inherited Members

Detailed Description

TheQ3GridView class provides an abstract base for fixed-size grids.

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 rownumRows()-1, columnnumCols()-1.

You can definenumRows,numCols,cellWidth andcellHeight. Reimplement the pure virtual functionpaintCell() to draw the contents of a cell.

WithensureCellVisible(), you can ensure a certain cell is visible. WithrowAt() andcolumnAt() you can find a cell based on the given x- and y-coordinates.

If you need to monitor changes to the grid's dimensions (i.e. whennumRows ornumCols is changed), reimplement thedimensionChange() change handler.

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).

Q3GridView is a very simple abstract class based onQ3ScrollView. 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 aQ3Table instead. If you need a simple list of items, use aQ3ListBox. If you need to present hierarichal data use aQ3ListView, and if you need random objects at random positions, consider using either aQ3IconView or aQ3Canvas.

Property Documentation

cellHeight :int

This property holds the height of a grid row.

All rows in a grid view have the same height.

Access functions:

intcellHeight() const
virtual voidsetCellHeight(int)

See alsocellWidth.

cellWidth :int

This property holds the width of a grid column.

All columns in a grid view have the same width.

Access functions:

intcellWidth() const
virtual voidsetCellWidth(int)

See alsocellHeight.

numCols :int

This property holds the number of columns in the grid.

Access functions:

intnumCols() const
virtual voidsetNumCols(int)

See alsonumRows.

numRows :int

This property holds the number of rows in the grid.

Access functions:

intnumRows() const
virtual voidsetNumRows(int)

See alsonumCols.

Member Function Documentation

Q3GridView::Q3GridView(QWidget * parent = 0, constchar * name = 0,Qt::WindowFlags f = 0)

Constructs a grid view.

Theparent,name and widget flag,f, arguments are passed to theQ3ScrollView constructor.

Q3GridView::~Q3GridView()

Destroys the grid view.

QRect Q3GridView::cellGeometry(int row,int column)

Returns the geometry of cell (row,column) in the content coordinate system.

See alsocellRect().

QRect Q3GridView::cellRect() const

Returns the geometry of a cell in a cell's coordinate system. This is a convenience function useful inpaintCell(). It is equivalent toQRect(0, 0,cellWidth(),cellHeight()).

See alsocellGeometry().

int Q3GridView::columnAt(int x) const

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

See alsorowAt().

[virtual protected]void Q3GridView::dimensionChange(int oldNumRows,int oldNumCols)

This change handler is called whenever any of the grid's dimensions change.oldNumRows andoldNumCols contain the old dimensions,numRows() andnumCols() contain the new dimensions.

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

Reimplemented fromQ3ScrollView::drawContents().

void Q3GridView::ensureCellVisible(int row,int column)

Ensures cell (row,column) is visible, scrolling the grid view if necessary.

QSize Q3GridView::gridSize() const

Returns the size of the grid in pixels.

[pure virtual protected]void Q3GridView::paintCell(QPainter * p,int row,int col)

This pure virtual function is called to paint the single cell at (row,col) using painterp. The painter must be open when paintCell() is called and must remain open.

The coordinate system istranslated so that the origin is at the top-left corner of the cell to be painted, i.e.cell coordinates. Do not scale or shear the coordinate system (or if you do, restore the transformation matrix before you return).

The painter is not clipped by default in order to get maximum efficiency. If you want clipping, use

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

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

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

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

void Q3GridView::repaintCell(int row,int column,bool erase = true)

Repaints cell (row,column).

Iferase is true, Qt erases the area of the cell before thepaintCell() call; otherwise no erasing takes place.

See alsoQWidget::repaint().

int Q3GridView::rowAt(int y) const

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

See alsocolumnAt().

void Q3GridView::updateCell(int row,int column)

Updates cell (row,column).

See alsoQWidget::update().

© 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