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  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

Object Trees and Object Ownership


QObjects organize themselves in object trees. When you create a QObject with another object as parent, it's added to the parent's children() list, and is deleted when the parent is. This turns out to fit the needs of GUI objects well. For example, a QAccel (keyboard accelerator) is a child of the right window, so when the user closes that window, the accelerator is deleted too.

The static function QObject::objectTrees() gives you access to all the root objects that currently exist.

QWidget, the base class of everything that shows up on the screen, extends the parent/child relationship: a child normally also becomes a so-called child widget, i.e. it is displayed in its parent's coordinate system and is graphically clipped by its parent's boundaries. Thus, when the the application deletes a message box after it's been closed, the message box' OK button is deleted too, just the way you would want, because the button is a child of the message box.

Of course, you can also delete a child object yourself, and it will remove itself from its parent. For example, when the user removes a toolbar that could often result in the application deleting one of the QToolBar objects, and the tool bar's QMainWindow parent would then notice the change and reconfigure its screen space.

The debugging functions QObject::dumpObjectTree() and QObject::dumpObjectInfo() are often useful when an application looks or acts strangely.

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 2.3
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