Qt:Документация 4.3.2/qgraphicssvgitem
Материал из Wiki.crossplatform.ru
Внимание: Актуальная версия перевода документации находится здесь |
__NOTOC__
Главная · Все классы · Основные классы · Классы по группам · Модули · Функции |
[править] QGraphicsSvgItem Class Reference
[модуль QtSvg ]
The QGraphicsSvgItem class is a QGraphicsItem that can be used to render the contents of SVG files. More...
#include <QGraphicsSvgItem>
Inherits QObject and QGraphicsItem.
This class was introduced in Qt 4.2.
[править] Открытые функции
- QGraphicsSvgItem ( QGraphicsItem * parent = 0 )
- QGraphicsSvgItem ( const QString & fileName, QGraphicsItem * parent = 0 )
- virtual QRectF boundingRect () const
- QString elementId () const
- bool isCachingEnabled () const
- QSize maximumCacheSize () const
- QSvgRenderer * renderer () const
- void setCachingEnabled ( bool caching )
- void setElementId ( const QString & id )
- void setMaximumCacheSize ( const QSize & size )
- void setSharedRenderer ( QSvgRenderer * renderer )
- 29 открытых функций унаследованных от QObject
- 114 открытых функций унаследованных от QGraphicsItem
[править] Дополнительные унаследованные члены
- 1 свойство унаследованное от QObject
- 1 открытый слот унаследованный от QObject
- 1 сигнал унаследованный от QObject
- 5 статических открытых члена унаследованных от QObject
- 1 static public member inherited from QGraphicsItem
- 7 защищенных функций унаследованных от QObject
- 23 защищенных функций унаследованных от QGraphicsItem
[править] Подробное описание
The QGraphicsSvgItem class is a QGraphicsItem that can be used to render the contents of SVG files.
QGraphicsSvgItem provides a way of rendering SVG files onto QGraphicsView. QGraphicsSvgItem can be created by passing the SVG file to be rendered to its constructor or by explicit setting a shared QSvgRenderer on it.
Note that setting QSvgRenderer on a QGraphicsSvgItem doesn't make the item take ownership of the renderer, therefore if using setSharedRenderer() method one has to make sure that the lifetime of the QSvgRenderer object will be at least as long as that of the QGraphicsSvgItem.
QGraphicsSvgItem provides a way of rendering only parts of the SVG files via the setElementId. If setElementId() method is called, only the SVG element (and its children) with the passed id will be renderer. This provides a convenient way of selectively rendering large SVG files that contain a number of discrete elements. For example the following code renders only jokers from a SVG file containing a whole card deck:
QSvgRenderer *renderer = new QSvgRenderer(QLatin1String("SvgCardDeck.svg")); QGraphicsSvgItem *black = new QGraphicsSvgItem(); QGraphicsSvgItem *red = new QGraphicsSvgItem(); black->setSharedRenderer(renderer); black->setElementId(QLatin1String("black_joker")); red->setSharedRenderer(renderer); red->setElementId(QLatin1String("red_joker"));
Size of the item can be set via the setSize() method or via direct manipulation of the items transformation matrix.
By default the SVG rendering is cached to speedup the display of items. Caching can be disabled by passing false to the setCachingEnabled() method.
See also QSvgWidget, QtSvg Module, QGraphicsItem, and QGraphicsView.
[править] Описание функций-членов
[править] QGraphicsSvgItem::QGraphicsSvgItem ( QGraphicsItem * parent = 0 )
Constructs a new SVG item with the given parent.
[править] QGraphicsSvgItem::QGraphicsSvgItem ( const QString & fileName, QGraphicsItem * parent = 0 )
Constructs a new item with the given parent and loads the contents of the SVG file with the specified fileName.
[править] QRectF QGraphicsSvgItem::boundingRect () const [virtual]
Returns the bounding rectangle of this item.
Reimplemented from QGraphicsItem.
[править] QString QGraphicsSvgItem::elementId () const
Returns the XML ID the element that is currently being renderer. Returns an empty string if the whole file is being rendered.
See also setElementId().
[править] bool QGraphicsSvgItem::isCachingEnabled () const
Returns true if the contents of the SVG file to be renderer is cached.
Note that caching will not work if either the amount of cached items exceeded QPixmapCache::cacheLimit() or if the current item on the given view is greater than the QGraphicsSvgItem::maximumCacheSize().
[править] QSize QGraphicsSvgItem::maximumCacheSize () const
Returns the current maximum size of the cache for this item.
This function doesn't take the current transformation matrix into account and returns the untransformed size. The default maximum cache size is 1024x768. QPixmapCache::cacheLimit() sets the cumulative bounds on the whole cache, maximumCacheSize refers to a maximum cache size for this particular item.
See also setMaximumCacheSize().
[править] QSvgRenderer * QGraphicsSvgItem::renderer () const
Returns the currently use QSvgRenderer.
[править] void QGraphicsSvgItem::setCachingEnabled ( bool caching )
If caching is true, enables caching on the item; otherwise disables it.
By default, caching is on. For performance reasons, it is advised to keep the caching enabled. Note that caching will not work if either the amount of cached items exceeded QPixmapCache::cacheLimit() or if the current item on the given view is greater than the QGraphicsSvgItem::maximumCacheSize().
See also isCachingEnabled().
[править] void QGraphicsSvgItem::setElementId ( const QString & id )
Sets the XML ID of the element that this item should render to id.
See also elementId().
[править] void QGraphicsSvgItem::setMaximumCacheSize ( const QSize & size )
Sets the maximum cache size of the item to size.
This function doesn't take the current transformation matrix into account and sets the untransformed size. The cache correspods to the QPixmap which is used to cache the results of the rendering. Use QPixmap::setCacheLimit() to set limitations on the whole cache and use setMaximumCacheSize when setting cache size for individual items.
See also maximumCacheSize().
[править] void QGraphicsSvgItem::setSharedRenderer ( QSvgRenderer * renderer )
Sets renderer to be a shared QSvgRenderer on the item. By using this method one can share the same QSvgRenderer on a number of items. This means that the SVG file will be parsed only once. QSvgRenderer passed to this method has to exist for as long as this item is used.
Copyright © 2007 Trolltech | Trademarks | Qt 4.3.2
|