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  · 

QGraphicsGridLayout Class Reference
[QtGui module]

The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View. More...

 #include <QGraphicsGridLayout>

Inherits QGraphicsLayout.

This class was introduced in Qt 4.4.


Public Functions

QGraphicsGridLayout ( QGraphicsLayoutItem * parent = 0 )
virtual ~QGraphicsGridLayout ()
void addItem ( QGraphicsLayoutItem * item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = 0 )
void addItem ( QGraphicsLayoutItem * item, int row, int column, Qt::Alignment alignment = 0 )
Qt::Alignment alignment ( QGraphicsLayoutItem * item ) const
Qt::Alignment columnAlignment ( int column ) const
int columnCount () const
qreal columnMaximumWidth ( int column ) const
qreal columnMinimumWidth ( int column ) const
qreal columnPreferredWidth ( int column ) const
qreal columnSpacing ( int column ) const
int columnStretchFactor ( int column ) const
qreal horizontalSpacing () const
QGraphicsLayoutItem * itemAt ( int row, int column ) const
Qt::Alignment rowAlignment ( int row ) const
int rowCount () const
qreal rowMaximumHeight ( int row ) const
qreal rowMinimumHeight ( int row ) const
qreal rowPreferredHeight ( int row ) const
qreal rowSpacing ( int row ) const
int rowStretchFactor ( int row ) const
void setAlignment ( QGraphicsLayoutItem * item, Qt::Alignment alignment )
void setColumnAlignment ( int column, Qt::Alignment alignment )
void setColumnFixedWidth ( int column, qreal width )
void setColumnMaximumWidth ( int column, qreal width )
void setColumnMinimumWidth ( int column, qreal width )
void setColumnPreferredWidth ( int column, qreal width )
void setColumnSpacing ( int column, qreal spacing )
void setColumnStretchFactor ( int column, int stretch )
void setHorizontalSpacing ( qreal spacing )
void setRowAlignment ( int row, Qt::Alignment alignment )
void setRowFixedHeight ( int row, qreal height )
void setRowMaximumHeight ( int row, qreal height )
void setRowMinimumHeight ( int row, qreal height )
void setRowPreferredHeight ( int row, qreal height )
void setRowSpacing ( int row, qreal spacing )
void setRowStretchFactor ( int row, int stretch )
void setSpacing ( qreal spacing )
void setVerticalSpacing ( qreal spacing )
qreal verticalSpacing () const

Reimplemented Public Functions

virtual int count () const
virtual void invalidate ()
virtual QGraphicsLayoutItem * itemAt ( int index ) const
virtual void removeAt ( int index )
virtual void setGeometry ( const QRectF & rect )
virtual QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const

Additional Inherited Members


Detailed Description

The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View.

The most common way to use QGraphicsGridLayout is to construct an object on the heap with no parent, add widgets and layouts by calling addItem(), and finally assign the layout to a widget by calling QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes the dimensions of the grid as you add items.

 QGraphicsScene scene;
 QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
 QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);

 QGraphicsGridLayout *layout = new QGraphicsGridLayout;
 layout->addItem(textEdit, 0, 0);
 layout->addItem(pushButton, 0, 1);

 QGraphicsWidget *form = new QGraphicsWidget;
 form->setLayout(layout);
 scene.addItem(form);

The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle this. You can access each item in the layout by calling count() and itemAt(). Calling removeAt() will remove an item from the layout, without destroying it.

See also QGraphicsLinearLayout and QGraphicsWidget.


Member Function Documentation

QGraphicsGridLayout::QGraphicsGridLayout ( QGraphicsLayoutItem * parent = 0 )

Constructs a QGraphicsGridLayout instance. parent is passed to QGraphicsLayout's constructor.

QGraphicsGridLayout::~QGraphicsGridLayout ()   [virtual]

Destroys the QGraphicsGridLayout object.

void QGraphicsGridLayout::addItem ( QGraphicsLayoutItem * item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = 0 )

Adds item to the grid on row and column. You can specify a rowSpan and columnSpan and an optional alignment.

void QGraphicsGridLayout::addItem ( QGraphicsLayoutItem * item, int row, int column, Qt::Alignment alignment = 0 )

Adds item to the grid on row and column. You can specify an optional alignment for item.

Qt::Alignment QGraphicsGridLayout::alignment ( QGraphicsLayoutItem * item ) const

Returns the alignment for item.

See also setAlignment().

Qt::Alignment QGraphicsGridLayout::columnAlignment ( int column ) const

Returns the alignment for column.

See also setColumnAlignment().

int QGraphicsGridLayout::columnCount () const

Returns the number of columns in the grid layout. This is always one more than the index of the last column that is occupied by a layout item (empty columns are counted except for those at the end).

qreal QGraphicsGridLayout::columnMaximumWidth ( int column ) const

Returns the maximum width for column.

See also setColumnMaximumWidth().

qreal QGraphicsGridLayout::columnMinimumWidth ( int column ) const

Returns the minimum width for column.

See also setColumnMinimumWidth().

qreal QGraphicsGridLayout::columnPreferredWidth ( int column ) const

Returns the preferred width for column.

See also setColumnPreferredWidth().

qreal QGraphicsGridLayout::columnSpacing ( int column ) const

Returns the column spacing for column.

See also setColumnSpacing().

int QGraphicsGridLayout::columnStretchFactor ( int column ) const

Returns the stretch factor for column.

See also setColumnStretchFactor().

int QGraphicsGridLayout::count () const   [virtual]

Reimplemented from QGraphicsLayout::count().

Returns the number of layout items in this grid layout.

qreal QGraphicsGridLayout::horizontalSpacing () const

Returns the default horizontal spacing for the grid layout.

See also setHorizontalSpacing().

void QGraphicsGridLayout::invalidate ()   [virtual]

Reimplemented from QGraphicsLayout::invalidate().

QGraphicsLayoutItem * QGraphicsGridLayout::itemAt ( int row, int column ) const

Returns a pointer to the layout item at (row, column).

QGraphicsLayoutItem * QGraphicsGridLayout::itemAt ( int index ) const   [virtual]

Reimplemented from QGraphicsLayout::itemAt().

Returns the layout item at index, or 0 if there is no layout item at this index.

void QGraphicsGridLayout::removeAt ( int index )   [virtual]

Reimplemented from QGraphicsLayout::removeAt().

Removes the layout item at index without destroying it. Ownership of the item is transferred to the caller.

See also addItem().

Qt::Alignment QGraphicsGridLayout::rowAlignment ( int row ) const

Returns the alignment of row.

See also setRowAlignment().

int QGraphicsGridLayout::rowCount () const

Returns the number of rows in the grid layout. This is always one more than the index of the last row that is occupied by a layout item (empty rows are counted except for those at the end).

qreal QGraphicsGridLayout::rowMaximumHeight ( int row ) const

Returns the maximum height for row, row.

See also setRowMaximumHeight().

qreal QGraphicsGridLayout::rowMinimumHeight ( int row ) const

Returns the minimum height for row, row.

See also setRowMinimumHeight().

qreal QGraphicsGridLayout::rowPreferredHeight ( int row ) const

Returns the preferred height for row, row.

See also setRowPreferredHeight().

qreal QGraphicsGridLayout::rowSpacing ( int row ) const

Returns the row spacing for row.

See also setRowSpacing().

int QGraphicsGridLayout::rowStretchFactor ( int row ) const

Returns the stretch factor for row.

See also setRowStretchFactor().

void QGraphicsGridLayout::setAlignment ( QGraphicsLayoutItem * item, Qt::Alignment alignment )

Sets the alignment for item to alignment.

See also alignment().

void QGraphicsGridLayout::setColumnAlignment ( int column, Qt::Alignment alignment )

Sets the alignment for column to alignment.

See also columnAlignment().

void QGraphicsGridLayout::setColumnFixedWidth ( int column, qreal width )

Sets the fixed width of column to width.

void QGraphicsGridLayout::setColumnMaximumWidth ( int column, qreal width )

Sets the maximum width of column to width.

See also columnMaximumWidth().

void QGraphicsGridLayout::setColumnMinimumWidth ( int column, qreal width )

Sets the minimum width for column to width.

See also columnMinimumWidth().

void QGraphicsGridLayout::setColumnPreferredWidth ( int column, qreal width )

Sets the preferred width for column to width.

See also columnPreferredWidth().

void QGraphicsGridLayout::setColumnSpacing ( int column, qreal spacing )

Sets the spacing for column to spacing.

See also columnSpacing().

void QGraphicsGridLayout::setColumnStretchFactor ( int column, int stretch )

Sets the stretch factor for column to stretch.

See also columnStretchFactor().

void QGraphicsGridLayout::setGeometry ( const QRectF & rect )   [virtual]

Reimplemented from QGraphicsLayoutItem::setGeometry().

Sets the bounding geometry of the grid layout to rect.

void QGraphicsGridLayout::setHorizontalSpacing ( qreal spacing )

Sets the default horizontal spacing for the grid layout to spacing.

See also horizontalSpacing().

void QGraphicsGridLayout::setRowAlignment ( int row, Qt::Alignment alignment )

Sets the alignment of row to alignment.

See also rowAlignment().

void QGraphicsGridLayout::setRowFixedHeight ( int row, qreal height )

Sets the fixed height for row, row, to height.

void QGraphicsGridLayout::setRowMaximumHeight ( int row, qreal height )

Sets the maximum height for row, row, to height.

See also rowMaximumHeight().

void QGraphicsGridLayout::setRowMinimumHeight ( int row, qreal height )

Sets the minimum height for row, row, to height.

See also rowMinimumHeight().

void QGraphicsGridLayout::setRowPreferredHeight ( int row, qreal height )

Sets the preferred height for row, row, to height.

See also rowPreferredHeight().

void QGraphicsGridLayout::setRowSpacing ( int row, qreal spacing )

Sets the spacing for row to spacing.

See also rowSpacing().

void QGraphicsGridLayout::setRowStretchFactor ( int row, int stretch )

Sets the stretch factor for row to stretch.

See also rowStretchFactor().

void QGraphicsGridLayout::setSpacing ( qreal spacing )

Sets the grid layout's default spacing, both vertical and horizontal, to spacing.

See also rowSpacing() and columnSpacing().

void QGraphicsGridLayout::setVerticalSpacing ( qreal spacing )

Sets the default vertical spacing for the grid layout to spacing.

See also verticalSpacing().

QSizeF QGraphicsGridLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const   [virtual]

Reimplemented from QGraphicsLayoutItem::sizeHint().

qreal QGraphicsGridLayout::verticalSpacing () const

Returns the default vertical spacing for the grid layout.

See also setVerticalSpacing().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 24
  2. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 46
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  6. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 95
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 50
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 24
  5. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 46
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Developer Network au hasard

Logo

Utiliser QML et QtWebKit avec PySide

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.6-snapshot
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