Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QPaintEngine Class

TheQPaintEngine class provides an abstract definition of howQPainter draws to a given device on a given platform.More...

Header:#include <QPaintEngine>
Inherited By:

QRasterPaintEngine

Public Types

enumDirtyFlag { DirtyPen, DirtyBrush, DirtyBrushOrigin, DirtyFont, ..., AllDirty }
flagsDirtyFlags
enumPaintEngineFeature { AlphaBlend, Antialiasing, BlendModes, BrushStroke, ..., AllFeatures }
flagsPaintEngineFeatures
enumPolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode }
enumType { X11, Windows, MacPrinter, CoreGraphics, ..., Blitter }

Public Functions

QPaintEngine(PaintEngineFeatures caps = 0)
virtual~QPaintEngine()
virtual boolbegin(QPaintDevice * pdev) = 0
virtual voiddrawEllipse(const QRectF & rect)
virtual voiddrawEllipse(const QRect & rect)
virtual voiddrawImage(const QRectF & rectangle, const QImage & image, const QRectF & sr, Qt::ImageConversionFlags flags = Qt::AutoColor)
virtual voiddrawLines(const QLineF * lines, int lineCount)
virtual voiddrawLines(const QLine * lines, int lineCount)
virtual voiddrawPath(const QPainterPath & path)
virtual voiddrawPixmap(const QRectF & r, const QPixmap & pm, const QRectF & sr) = 0
virtual voiddrawPoints(const QPointF * points, int pointCount)
virtual voiddrawPoints(const QPoint * points, int pointCount)
virtual voiddrawPolygon(const QPointF * points, int pointCount, PolygonDrawMode mode)
virtual voiddrawPolygon(const QPoint * points, int pointCount, PolygonDrawMode mode)
virtual voiddrawRects(const QRectF * rects, int rectCount)
virtual voiddrawRects(const QRect * rects, int rectCount)
virtual voiddrawTextItem(const QPointF & p, const QTextItem & textItem)
virtual voiddrawTiledPixmap(const QRectF & rect, const QPixmap & pixmap, const QPointF & p)
virtual boolend() = 0
boolhasFeature(PaintEngineFeatures feature) const
boolisActive() const
QPaintDevice *paintDevice() const
QPainter *painter() const
voidsetActive(bool state)
virtual Typetype() const = 0
virtual voidupdateState(const QPaintEngineState & state) = 0

Detailed Description

TheQPaintEngine class provides an abstract definition of howQPainter draws to a given device on a given platform.

Qt 4.0 provides several premade implementations ofQPaintEngine for the different painter backends we support. We provide one paint engine for each window system and painting framework we support. This includes X11 on Unix/Linux andCoreGraphics on Mac OS X. In addition we provideQPaintEngine implementations forOpenGL (accessible throughQGLWidget) andPostScript (accessible through QPSPrinter on X11). Additionally there is a raster-based paint engine that is a fallback for when an engine does not support a certain capability.

If one wants to useQPainter to draw to a different backend, one must subclassQPaintEngine and reimplement all its virtual functions. TheQPaintEngine implementation is then made available by subclassingQPaintDevice and reimplementing the virtual functionQPaintDevice::paintEngine().

QPaintEngine is created and owned by theQPaintDevice that created it.

The big advantage of theQPaintEngine approach opposed to Qt 3'sQPainter/QPaintDevice::cmd() approach is that it is now possible to adapt to multiple technologies on each platform and take advantage of each to the fullest.

See alsoQPainter,QPaintDevice::paintEngine(), andPaint System.

Member Type Documentation

enum QPaintEngine::DirtyFlag
flags QPaintEngine::DirtyFlags

ConstantValueDescription
QPaintEngine::DirtyPen0x0001The pen is dirty and needs to be updated.
QPaintEngine::DirtyBrush0x0002The brush is dirty and needs to be updated.
QPaintEngine::DirtyBrushOrigin0x0004The brush origin is dirty and needs to updated.
QPaintEngine::DirtyFont0x0008The font is dirty and needs to be updated.
QPaintEngine::DirtyBackground0x0010The background is dirty and needs to be updated.
QPaintEngine::DirtyBackgroundMode0x0020The background mode is dirty and needs to be updated.
QPaintEngine::DirtyTransform0x0040The transform is dirty and needs to be updated.
QPaintEngine::DirtyClipRegion0x0080The clip region is dirty and needs to be updated.
QPaintEngine::DirtyClipPath0x0100The clip path is dirty and needs to be updated.
QPaintEngine::DirtyHints0x0200The render hints is dirty and needs to be updated.
QPaintEngine::DirtyCompositionMode0x0400The composition mode is dirty and needs to be updated.
QPaintEngine::DirtyClipEnabled0x0800Whether clipping is enabled or not is dirty and needs to be updated.
QPaintEngine::DirtyOpacity0x1000The constant opacity has changed and needs to be updated as part of the state change inQPaintEngine::updateState().
QPaintEngine::AllDirty0xffffConvenience enum used internally.

These types are used byQPainter to trigger lazy updates of the various states in theQPaintEngine usingQPaintEngine::updateState().

A paint engine must update every dirty state.

The DirtyFlags type is a typedef forQFlags<DirtyFlag>. It stores an OR combination of DirtyFlag values.

enum QPaintEngine::PaintEngineFeature
flags QPaintEngine::PaintEngineFeatures

This enum is used to describe the features or capabilities that the paint engine has. If a feature is not supported by the engine,QPainter will do a best effort to emulate that feature through other means and pass on an alpha blendedQImage to the engine with the emulated results. Some features cannot be emulated: AlphaBlend and PorterDuff.

ConstantValueDescription
QPaintEngine::AlphaBlend0x00000080The engine can alpha blend primitives.
QPaintEngine::Antialiasing0x00000400The engine can use antialising to improve the appearance of rendered primitives.
QPaintEngine::BlendModes0x00008000The engine supports blending modes.
QPaintEngine::BrushStroke0x00000800The engine supports drawing strokes that contain brushes as fills, not just solid colors (e.g. a dashed gradient line of width 2).
QPaintEngine::ConicalGradientFill0x00000040The engine supports conical gradient fills.
QPaintEngine::ConstantOpacity0x00001000The engine supports the feature provided byQPainter::setOpacity().
QPaintEngine::LinearGradientFill0x00000010The engine supports linear gradient fills.
QPaintEngine::MaskedBrush0x00002000The engine is capable of rendering brushes that has a texture with an alpha channel or a mask.
QPaintEngine::ObjectBoundingModeGradients0x00010000The engine has native support for gradients with coordinate modeQGradient::ObjectBoundingMode. Otherwise, if QPaintEngine::PatternTransform is supported, object bounding mode gradients are converted to gradients with coordinate modeQGradient::LogicalMode and a brush transform for the coordinate mapping.
QPaintEngine::PainterPaths0x00000200The engine has path support.
QPaintEngine::PaintOutsidePaintEvent0x20000000The engine is capable of painting outside of paint events.
QPaintEngine::PatternBrush0x00000008The engine is capable of rendering brushes with the brush patterns specified inQt::BrushStyle.
QPaintEngine::PatternTransform0x00000002The engine has support for transforming brush patterns.
QPaintEngine::PerspectiveTransform0x00004000The engine has support for performing perspective transformations on primitives.
QPaintEngine::PixmapTransform0x00000004The engine can transform pixmaps, including rotation and shearing.
QPaintEngine::PorterDuff0x00000100The engine supports Porter-Duff operations
QPaintEngine::PrimitiveTransform0x00000001The engine has support for transforming drawing primitives.
QPaintEngine::RadialGradientFill0x00000020The engine supports radial gradient fills.
QPaintEngine::RasterOpModes0x00020000The engine supports bitwise raster operations.
QPaintEngine::AllFeatures0xffffffffAll of the above features. This enum value is usually used as a bit mask.

The PaintEngineFeatures type is a typedef forQFlags<PaintEngineFeature>. It stores an OR combination of PaintEngineFeature values.

enum QPaintEngine::PolygonDrawMode

ConstantValueDescription
QPaintEngine::OddEvenMode0The polygon should be drawn using OddEven fill rule.
QPaintEngine::WindingMode1The polygon should be drawn using Winding fill rule.
QPaintEngine::ConvexMode2The polygon is a convex polygon and can be drawn using specialized algorithms where available.
QPaintEngine::PolylineMode3Only the outline of the polygon should be drawn.

enum QPaintEngine::Type

ConstantValueDescription
QPaintEngine::X110 
QPaintEngine::Windows1 
QPaintEngine::MacPrinter4 
QPaintEngine::CoreGraphics3Mac OS X's Quartz2D (CoreGraphics)
QPaintEngine::QuickDraw2Mac OS X's QuickDraw
QPaintEngine::QWindowSystem5Qt for Embedded Linux
QPaintEngine::PostScript6 
QPaintEngine::OpenGL7 
QPaintEngine::Picture8QPicture format
QPaintEngine::SVG9Scalable Vector Graphics XML format
QPaintEngine::Raster10 
QPaintEngine::Direct3D11Windows only, Direct3D based engine
QPaintEngine::Pdf12Portable Document Format
QPaintEngine::OpenVG13 
QPaintEngine::User50First user type ID
QPaintEngine::MaxUser100Last user type ID
QPaintEngine::OpenGL214 
QPaintEngine::PaintBuffer15 
QPaintEngine::Blitter16 

Member Function Documentation

QPaintEngine::QPaintEngine(PaintEngineFeatures caps = 0)

Creates a paint engine with the featureset specified bycaps.

[virtual]QPaintEngine::~QPaintEngine()

Destroys the paint engine.

[pure virtual]bool QPaintEngine::begin(QPaintDevice * pdev)

Reimplement this function to initialise your paint engine when painting is to start on the paint devicepdev. Return true if the initialization was successful; otherwise return false.

See alsoend() andisActive().

[virtual]void QPaintEngine::drawEllipse(constQRectF & rect)

Reimplement this function to draw the largest ellipse that can be contained within rectanglerect.

The default implementation callsdrawPolygon().

[virtual]void QPaintEngine::drawEllipse(constQRect & rect)

The default implementation of this function calls the floating point version of this function

[virtual]void QPaintEngine::drawImage(constQRectF & rectangle, constQImage & image, constQRectF & sr,Qt::ImageConversionFlags flags = Qt::AutoColor)

Reimplement this function to draw the part of theimage specified by thesr rectangle in the givenrectangle using the given conversion flagsflags, to convert it to a pixmap.

[virtual]void QPaintEngine::drawLines(constQLineF * lines,int lineCount)

The default implementation splits the list of lines inlines intolineCount separate calls todrawPath() ordrawPolygon() depending on the feature set of the paint engine.

[virtual]void QPaintEngine::drawLines(constQLine * lines,int lineCount)

This is an overloaded function.

The default implementation converts the firstlineCount lines inlines to aQLineF and calls the floating point version of this function.

[virtual]void QPaintEngine::drawPath(constQPainterPath & path)

The default implementation ignores thepath and does nothing.

[pure virtual]void QPaintEngine::drawPixmap(constQRectF & r, constQPixmap & pm, constQRectF & sr)

Reimplement this function to draw the part of thepm specified by thesr rectangle in the givenr.

[virtual]void QPaintEngine::drawPoints(constQPointF * points,int pointCount)

Draws the firstpointCount points in the bufferpoints

[virtual]void QPaintEngine::drawPoints(constQPoint * points,int pointCount)

Draws the firstpointCount points in the bufferpoints

The default implementation converts the firstpointCount QPoints inpoints to QPointFs and calls the floating point version ofdrawPoints.

[virtual]void QPaintEngine::drawPolygon(constQPointF * points,int pointCount,PolygonDrawMode mode)

Reimplement this virtual function to draw the polygon defined by thepointCount first points inpoints, using modemode.

Note:At least one of the drawPolygon() functions must be reimplemented.

[virtual]void QPaintEngine::drawPolygon(constQPoint * points,int pointCount,PolygonDrawMode mode)

This is an overloaded function.

Reimplement this virtual function to draw the polygon defined by thepointCount first points inpoints, using modemode.

Note:At least one of thedrawPolygon() functions must be reimplemented.

[virtual]void QPaintEngine::drawRects(constQRectF * rects,int rectCount)

Draws the firstrectCount rectangles in the bufferrects. The default implementation of this function callsdrawPath() ordrawPolygon() depending on the feature set of the paint engine.

[virtual]void QPaintEngine::drawRects(constQRect * rects,int rectCount)

This is an overloaded function.

The default implementation converts the firstrectCount rectangles in the bufferrects to aQRectF and calls the floating point version of this function.

[virtual]void QPaintEngine::drawTextItem(constQPointF & p, constQTextItem & textItem)

This function draws the text itemtextItem at positionp. The default implementation of this function converts the text to aQPainterPath and paints the resulting path.

[virtual]void QPaintEngine::drawTiledPixmap(constQRectF & rect, constQPixmap & pixmap, constQPointF & p)

Reimplement this function to draw thepixmap in the givenrect, starting at the givenp. The pixmap will be drawn repeatedly until therect is filled.

[pure virtual]bool QPaintEngine::end()

Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.

See alsobegin() andisActive().

bool QPaintEngine::hasFeature(PaintEngineFeatures feature) const

Returns true if the paint engine supports the specifiedfeature; otherwise returns false.

bool QPaintEngine::isActive() const

Returns true if the paint engine is actively drawing; otherwise returns false.

See alsosetActive().

QPaintDevice * QPaintEngine::paintDevice() const

Returns the device that this engine is painting on, if painting is active; otherwise returns 0.

QPainter * QPaintEngine::painter() const

Returns the paint engine's painter.

void QPaintEngine::setActive(bool state)

Sets the active state of the paint engine tostate.

See alsoisActive().

[pure virtual]Type QPaintEngine::type() const

Reimplement this function to return the paint engineType.

[pure virtual]void QPaintEngine::updateState(constQPaintEngineState & state)

Reimplement this function to update the state of a paint engine.

When implemented, this function is responsible for checking the paint engine's currentstate and update the properties that are changed. Use theQPaintEngineState::state() function to find out which properties that must be updated, then use the correspondingget function to retrieve the current values for the given properties.

See alsoQPaintEngineState.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp