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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QGraphicsItemGroup Class Reference
[QtGui module]

The QGraphicsItemGroup class provides treating a group of items as one. More...

 #include <QGraphicsItemGroup>

Inherits QGraphicsItem.

This class was introduced in Qt 4.2.

Public Functions

Additional Inherited Members


Detailed Description

The QGraphicsItemGroup class provides treating a group of items as one.

A QGraphicsItemGroup is a special type of compound item that treats itself and all its children as one item (i.e., all events and geometries for all children are merged together). It's common to use item groups in presentation tools, when the user wants to group several smaller items into one big item in order to simplify moving and copying of items.

If all you want is to store items inside other items, you can use any QGraphicsItem directly by passing a suitable parent to setParentItem().

The boundingRect() function of QGraphicsItemGroup returns the bounding rectangle of all items in the item group. In addition, item groups have handlesChildEvents() enabled by default, so all events sent to a member of the group go to the item group (i.e., selecting one item in a group will select them all).

There are two ways to construct an item group. The easiest and most common approach is to pass a list of items (e.g., all selected items) to QGraphicsScene::createItemGroup(), which returns a new QGraphicsItemGroup item. The other approach is to manually construct a QGraphicsItemGroup item, add it to the scene calling QGraphicsScene::addItem(), and then add items to the group manually, one at a time by calling addToGroup(). To dismantle ("ungroup") an item group, you can either call QGraphicsScene::destroyItemGroup(), or you can manually remove all items from the group by calling removeFromGroup().

 // Group all selected items together
 QGraphicsItemGroup *group = scene->createItemGroup(scene->selecteditems());

 // Destroy the group, and delete the group item
 scene->destroyItemGroup(group);

The operation of adding and removing items preserves the items' scene-relative position and transformation, as opposed to calling setParentItem(), where only the child item's parent-relative position and transformation are kept.

The addtoGroup() function reparents the target item to this item group, keeping the item's position and transformation intact relative to the scene. Visually, this means that items added via addToGroup() will remain completely unchanged as a result of this operation, regardless of the item or the group's current position or transformation; although the item's position and matrix are likely to change.

The removeFromGroup() function has similar semantics to setParentItem(); it reparents the item to the parent item of the item group. As with addToGroup(), the item's scene-relative position and transformation remain intact.

See also QGraphicsItem and The Graphics View Framework.


Member Function Documentation

QGraphicsItemGroup::QGraphicsItemGroup ( QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 )

Constructs a QGraphicsItemGroup. The parent and scene parameters are passed to QGraphicsItem's constructor.

QGraphicsItemGroup::~QGraphicsItemGroup ()

Destroys the QGraphicsItemGroup.

void QGraphicsItemGroup::addToGroup ( QGraphicsItem * item )

Adds the given item to this item group. The item will be reparented to this group, but its position and transformation relative to the scene will stay intact.

See also removeFromGroup() and QGraphicsScene::createItemGroup().

void QGraphicsItemGroup::removeFromGroup ( QGraphicsItem * item )

Removes the specified item from this group. The item will be reparented to this group's parent item, or to 0 if this group has no parent. Its position and transformation relative to the scene will stay intact.

See also addToGroup() and QGraphicsScene::destroyItemGroup().

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