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  · 

Q3CanvasPixmapArray Class Reference
[Qt3Support module]

The Q3CanvasPixmapArray class provides an array of Q3CanvasPixmaps. More...

 #include <Q3CanvasPixmapArray>

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.

Note to Qt Desktop Light Edition users: This class is only available in the Qt Desktop Edition.

Public Functions


Detailed Description

The Q3CanvasPixmapArray class provides an array of Q3CanvasPixmaps.

This class is used by Q3CanvasSprite to hold an array of pixmaps. It is used to implement animated sprites, i.e. images that change over time, with each pixmap in the array holding one frame.

Depending on the constructor you use you can load multiple pixmaps into the array either from a directory (specifying a wildcard pattern for the files), or from a list of QPixmaps. You can also read in a set of pixmaps after construction using readPixmaps().

Individual pixmaps can be set with setImage() and retrieved with image(). The number of pixmaps in the array is returned by count().

Q3CanvasSprite uses an image's mask for collision detection. You can change this by reading in a separate set of image masks using readCollisionMasks().

See also QtCanvas and Porting to Graphics View.


Member Function Documentation

Q3CanvasPixmapArray::Q3CanvasPixmapArray ()

Constructs an invalid array (i.e. isValid() will return false). You must call readPixmaps() before being able to use this Q3CanvasPixmapArray.

Q3CanvasPixmapArray::Q3CanvasPixmapArray ( const QString & datafilenamepattern, int fc = 0 )

Constructs a Q3CanvasPixmapArray from files.

The fc parameter sets the number of frames to be loaded for this image.

If fc is not 0, datafilenamepattern should contain "%1", e.g. "foo%1.png". The actual filenames are formed by replacing the %1 with four-digit integers from 0 to (fc - 1), e.g. foo0000.png, foo0001.png, foo0002.png, etc.

If fc is 0, datafilenamepattern is asssumed to be a filename, and the image contained in this file will be loaded as the first (and only) frame.

If datafilenamepattern does not exist, is not readable, isn't an image, or some other error occurs, the array ends up empty and isValid() returns false.

Q3CanvasPixmapArray::Q3CanvasPixmapArray ( Q3ValueList<QPixmap> list, Q3PointArray hotspots = Q3PointArray() )

Constructs a Q3CanvasPixmapArray from the list of QPixmaps in the list. Each pixmap will get a hotspot according to the hotspots array. If no hotspots are specified, each one is set to be at position (0, 0).

If an error occurs, isValid() will return false.

Q3CanvasPixmapArray::~Q3CanvasPixmapArray ()

Destroys the pixmap array and all the pixmaps it contains.

uint Q3CanvasPixmapArray::count () const

Returns the number of pixmaps in the array.

Q3CanvasPixmap * Q3CanvasPixmapArray::image ( int i ) const

Returns pixmap i in the array, if i is non-negative and less than than count(), and returns an unspecified value otherwise.

See also setImage().

bool Q3CanvasPixmapArray::isValid () const

Returns true if the pixmap array is valid; otherwise returns false.

bool Q3CanvasPixmapArray::readCollisionMasks ( const QString & filename )

Reads new collision masks for the array.

By default, Q3CanvasSprite uses the image mask of a sprite to detect collisions. Use this function to set your own collision image masks.

If count() is 1 filename must specify a real filename to read the mask from. If count() is greater than 1, the filename must contain a "%1" that will get replaced by the number of the mask to be loaded, just like Q3CanvasPixmapArray::readPixmaps().

All collision masks must be 1-bit images or this function call will fail.

If the file isn't readable, contains the wrong number of images, or there is some other error, this function will return false, and the array will be flagged as invalid; otherwise this function returns true.

See also isValid().

bool Q3CanvasPixmapArray::readPixmaps ( const QString & filenamepattern, int fc = 0 )

Reads one or more pixmaps into the pixmap array.

If fc is not 0, filenamepattern should contain "%1", e.g. "foo%1.png". The actual filenames are formed by replacing the %1 with four-digit integers from 0 to (fc - 1), e.g. foo0000.png, foo0001.png, foo0002.png, etc.

If fc is 0, filenamepattern is asssumed to be a filename, and the image contained in this file will be loaded as the first (and only) frame.

If filenamepattern does not exist, is not readable, isn't an image, or some other error occurs, this function will return false, and isValid() will return false; otherwise this function will return true.

See also isValid().

void Q3CanvasPixmapArray::setImage ( int i, Q3CanvasPixmap * p )

Replaces the pixmap at index i with pixmap p.

The array takes ownership of p and will delete p when the array itself is deleted.

If i is beyond the end of the array the array is extended to at least i+1 elements, with elements count() to i-1 being initialized to 0.

See also image().

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