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  · 

QThumbnail Class Reference
[QtBaseModule]

The QThumbnail class provides thumbnails of large images. More...

    #include <QThumbnail>

Public Functions

  • QThumbnail ( const QString & fileName )
  • QThumbnail ( QIODevice * device )
  • QSize actualSize ( const QSize & size = QSize(), Qt::AspectRatioMode mode = Qt::KeepAspectRatio )
  • QPixmap pixmap ( const QSize & size, Qt::AspectRatioMode mode = Qt::KeepAspectRatio, Qt::TransformationMode transformationMode = Qt::FastTransformation )

Detailed Description

The QThumbnail class provides thumbnails of large images.

A thumbnail is a small version of an image loaded from a file or QIODevice.

Thumbnail pixmaps are generated by calling pixmap(maximum_size). Usually, aspect ratio is preserved, so the actualSize() of the image may have a smaller width or height than the maximum size.

For many image formats, thumbnails are loaded by methods more efficient than the naive method of simply loading the entire image and scaling it down. For other formats, the naive method is used.

This code paints the contents of image.jpg centered on the calling widget:

    QPainter painter( this );

    QThumbnail thumbnail( "image.jpg" );
    offset = (size() - thumbnail.actualSize(size())) / 2;
    painter.drawPixmap( offset.width(), offset.height(), thumbnail.pixmap(size()));

Member Function Documentation

QThumbnail::QThumbnail ( const QString & fileName )

Constructs the thumbnail for the given image fileName. The file is not loaded at this time, but it is opened.

QThumbnail::QThumbnail ( QIODevice * device )

Constructs the thumbnail for an image to be read from the given io device.

QThumbnail::~QThumbnail ()

Destroys the thumbnail.

QSize QThumbnail::actualSize ( const QSize & size = QSize(), Qt::AspectRatioMode mode = Qt::KeepAspectRatio )

Returns the actual size of the thumbnail for the requested size and mode. An invalid size is returned if the image is not able to be read. The whole image may be loaded if the image handler does not support the QImageIOHandler::Size option.

If size is invalid the function returns the size as defined by QImageIOHandler::Size. This can be used to prevent that the image is scaled up when calling QThumbnail::pixmap():

    thumbnail.pixmap(
        thumbnail.actualSize(
            maxsize.boundedTo(
                thumbnail.actualSize(QSize())
            )
        )
    )

See also pixmap().

QPixmap QThumbnail::pixmap ( const QSize & size, Qt::AspectRatioMode mode = Qt::KeepAspectRatio, Qt::TransformationMode transformationMode = Qt::FastTransformation )

Returns a pixmap with the requested size and mode. A null pixmap is returned if the image cannot be loaded.

The pixmap will be generated by scaling the image as it is being loaded where possible. This is reliant on the support for the QImageIOHandler::ScaledSize option in the image handler. If the option is not supported the whole image will be loaded and then scaled with the requested transformationMode.

See also actualSize().

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 qtextended4.4
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