Notice: Undefined offset: 1 in /home/developpez/www/developpez-com/upload/qt/doc/redir.php on line 39 Qt 4.7: Q3GridView Class Reference
Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Q3GridView Class Reference

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

 #include <Q3GridView>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits: Q3ScrollView.

Properties

Public Functions

Q3GridView ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )
~Q3GridView ()
QRect cellGeometry ( int row, int column )
int cellHeight () const
QRect cellRect () const
int cellWidth () const
int columnAt ( int x ) const
void ensureCellVisible ( int row, int column )
QSize gridSize () const
int numCols () const
int numRows () const
void repaintCell ( int row, int column, bool erase = true )
int rowAt ( int y ) const
virtual void setCellHeight ( int )
virtual void setCellWidth ( int )
virtual void setNumCols ( int )
virtual void setNumRows ( int )
void updateCell ( int row, int column )
  • 49 public functions inherited from Q3ScrollView
  • 4 public functions inherited from Q3Frame
  • 14 public functions inherited from QFrame
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Protected Functions

virtual void dimensionChange ( int oldNumRows, int oldNumCols )
virtual void paintCell ( QPainter * p, int row, int col ) = 0
virtual void paintEmptyArea ( QPainter * p, int cx, int cy, int cw, int ch )

Reimplemented Protected Functions

virtual void drawContents ( QPainter * p, int cx, int cy, int cw, int ch )
  • 26 protected functions inherited from Q3ScrollView
  • 5 protected functions inherited from Q3Frame
  • 3 protected functions inherited from QFrame
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

Detailed Description

The Q3GridView 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 row numRows()-1, column numCols()-1.

You can define numRows, numCols, cellWidth and cellHeight. Reimplement the pure virtual function paintCell() to draw the contents of a cell.

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.

If you need to monitor changes to the grid's dimensions (i.e. when numRows or numCols is changed), reimplement the dimensionChange() 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 on Q3ScrollView. 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 Q3Table instead. If you need a simple list of items, use a Q3ListBox. If you need to present hierarichal data use a Q3ListView, and if you need random objects at random positions, consider using either a Q3IconView or a Q3Canvas.

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:

int cellHeight () const
virtual void setCellHeight ( int )

See also cellWidth.

cellWidth : int

This property holds the width of a grid column.

All columns in a grid view have the same width.

Access functions:

int cellWidth () const
virtual void setCellWidth ( int )

See also cellHeight.

numCols : int

This property holds the number of columns in the grid.

Access functions:

int numCols () const
virtual void setNumCols ( int )

See also numRows.

numRows : int

This property holds the number of rows in the grid.

Access functions:

int numRows () const
virtual void setNumRows ( int )

See also numCols.

Member Function Documentation

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

Constructs a grid view.

The parent, name and widget flag, f, arguments are passed to the Q3ScrollView 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 also cellRect().

QRect Q3GridView::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()).

See also cellGeometry().

int Q3GridView::columnAt ( int x ) const

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

See also rowAt().

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

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

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

Reimplemented from Q3ScrollView::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.

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

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

The coordinate system is translated 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 code
 p->setClipping(false);

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

This function fills the cw pixels wide and ch pixels high rectangle starting at position (cx, cy) with the background color using the painter p.

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

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

Repaints cell (row, column).

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

See also QWidget::repaint().

int Q3GridView::rowAt ( int y ) const

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

See also columnAt().

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

Updates cell (row, column).

See also QWidget::update().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web