📄 qpainter.3qt
字号:
.SH "void QPainter::save ()"Saves the current painter state (pushes the state onto a stack). A save() must be followed by a corresponding restore(). end() unwinds the stack..PPSee also restore()..PPExample: aclock/aclock.cpp..SH "void QPainter::saveWorldMatrix ()"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPWe recommend using save() instead..SH "void QPainter::scale ( double sx, double sy )"Scales the coordinate system by \fI(sx, sy)\fR..PPSee also translate(), shear(), rotate(), resetXForm(), setWorldMatrix(), and xForm()..PPExample: xform/xform.cpp..SH "void QPainter::setBackgroundColor ( const QColor & c )"Sets the background color of the painter to \fIc\fR..PPThe background color is the color that is filled in when drawing opaque text, stippled lines and bitmaps. The background color has no effect in transparent background mode (which is the default)..PPSee also backgroundColor(), setBackgroundMode(), and BackgroundMode..SH "void QPainter::setBackgroundMode ( BGMode m )"Sets the background mode of the painter to \fIm\fR, which must be either TransparentMode (the default) or OpaqueMode..PPTransparent mode draws stippled lines and text without setting the background pixels. Opaque mode fills these space with the current background color..PPNote that in order to draw a bitmap or pixmap transparently, you must use QPixmap::setMask()..PPSee also backgroundMode() and setBackgroundColor()..PPExample: picture/picture.cpp..SH "void QPainter::setBrush ( BrushStyle style )"Sets the painter's brush to black color and the specified \fIstyle\fR..PPSee also brush() and QBrush..PPExamples:.)l aclock/aclock.cpp, drawdemo/drawdemo.cpp, picture/picture.cpp, t10/cannon.cpp, t9/cannon.cpp, themes/wood.cpp, and tooltip/tooltip.cpp..SH "void QPainter::setBrush ( const QBrush & brush )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the painter's brush to \fIbrush\fR..PPThe \fIbrush\fR defines how shapes are filled..PPSee also brush()..SH "void QPainter::setBrush ( const QColor & color )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the painter's brush to have style SolidPattern and the specified \fIcolor\fR..PPSee also brush() and QBrush..SH "void QPainter::setBrushOrigin ( int x, int y )"Sets the brush origin to \fI(x, y)\fR..PPThe brush origin specifies the (0, 0) coordinate of the painter's brush. This setting only applies to pattern brushes and pixmap brushes..PPSee also brushOrigin()..SH "void QPainter::setBrushOrigin ( const QPoint & p )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the brush origin to point \fIp\fR..SH "void QPainter::setClipRect ( int x, int y, int w, int h, CoordinateMode m = CoordDevice )"Sets the clip region to the rectangle \fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR and enables clipping. The clip mode is set to \fIm\fR..PPNote that the clip region is given in physical device coordinates and \fInot\fR subject to any coordinate transformation if \fIm\fR is equal to CoordDevice (the default). If \fIm\fR equals CoordPainter the returned region is in model coordinates..PPSee also setClipRegion(), clipRegion(), setClipping(), and QPainter::CoordinateMode..PPExamples:.)l progress/progress.cpp, showimg/showimg.cpp, and splitter/splitter.cpp..SH "void QPainter::setClipRect ( const QRect & r, CoordinateMode m = CoordDevice )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the clip region to the rectangle \fIr\fR and enables clipping. The clip mode is set to \fIm\fR..PPSee also CoordinateMode..SH "void QPainter::setClipRegion ( const QRegion & rgn, CoordinateMode m = CoordDevice )"Sets the clip region to \fIrgn\fR and enables clipping. The clip mode is set to \fIm\fR..PPNote that the clip region is given in physical device coordinates and \fInot\fR subject to any coordinate transformation..PPSee also setClipRect(), clipRegion(), setClipping(), and CoordinateMode..PPExamples:.)l qfd/fontdisplayer.cpp and themes/wood.cpp..SH "void QPainter::setClipping ( bool enable )"Enables clipping if \fIenable\fR is TRUE, or disables clipping if \fIenable\fR is FALSE..PPSee also hasClipping(), setClipRect(), and setClipRegion()..PPExample: themes/wood.cpp..SH "void QPainter::setFont ( const QFont & font )"Sets the painter's font to \fIfont\fR..PPThis font is used by subsequent drawText() functions. The text color is the same as the pen color..PPSee also font() and drawText()..PPExamples:.)l action/application.cpp, application/application.cpp, drawdemo/drawdemo.cpp, hello/hello.cpp, picture/picture.cpp, t13/cannon.cpp, and xform/xform.cpp..SH "void QPainter::setPen ( const QPen & pen )"Sets a new painter pen..PPThe \fIpen\fR defines how to draw lines and outlines, and it also defines the text color..PPSee also pen()..PPExamples:.)l desktop/desktop.cpp, drawdemo/drawdemo.cpp, progress/progress.cpp, t10/cannon.cpp, t9/cannon.cpp, themes/metal.cpp, and themes/wood.cpp..SH "void QPainter::setPen ( PenStyle style )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the painter's pen to have style \fIstyle\fR, width 0 and black color..PPSee also pen() and QPen..SH "void QPainter::setPen ( const QColor & color )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the painter's pen to have style SolidLine, width 0 and the specified \fIcolor\fR..PPSee also pen() and QPen..SH "void QPainter::setRasterOp ( RasterOp r )"Sets the raster operation to \fIr\fR. The default is CopyROP..PPSee also rasterOp() and Qt::RasterOp..SH "void QPainter::setTabArray ( int * ta )"Sets the tab stop array to \fIta\fR. This puts tab stops at \fIta[0]\fR, \fIta[1]\fR and so on. The array is null-terminated..PPIf both a tab array and a tab top size is set, the tab array wins..PPSee also tabArray(), setTabStops(), drawText(), and fontMetrics()..SH "void QPainter::setTabStops ( int ts )"Set the tab stop width to \fIts\fR, i.e. locates tab stops at \fIts\fR, 2*\fIts\fR, 3*\fIts\fR and so on..PPTab stops are used when drawing formatted text with ExpandTabs set. This fixed tab stop value is used only if no tab array is set (which is the default case)..PPSee also tabStops(), setTabArray(), drawText(), and fontMetrics()..SH "void QPainter::setViewXForm ( bool enable )"Enables view transformations if \fIenable\fR is TRUE, or disables view transformations if \fIenable\fR is FALSE..PPSee also hasViewXForm(), setWindow(), setViewport(), setWorldMatrix(), setWorldXForm(), and xForm()..SH "void QPainter::setViewport ( int x, int y, int w, int h )"Sets the viewport rectangle view transformation for the painter and enables view transformation..PPThe viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system and is specified by the \fIx\fR, \fIy\fR, \fIw\fR width and \fIh\fR height parameters. Its sister, the window(), specifies the logical coordinate system..PPThe default viewport rectangle is the same as the device's rectangle. See the Coordinate System Overview for an overview of coordinate transformation..PPSee also viewport(), setWindow(), setViewXForm(), setWorldMatrix(), setWorldXForm(), and xForm()..PPExample: aclock/aclock.cpp..SH "void QPainter::setViewport ( const QRect & r )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the painter's viewport to rectangle \fIr\fR..SH "void QPainter::setWindow ( int x, int y, int w, int h )"Sets the window rectangle view transformation for the painter and enables view transformation..PPThe window rectangle is part of the view transformation. The window specifies the logical coordinate system and is specified by the \fIx\fR, \fIy\fR, \fIw\fR width and \fIh\fR height parameters. Its sister, the viewport(), specifies the device coordinate system..PPThe default window rectangle is the same as the device's rectangle. See the Coordinate System Overview for an overview of coordinate transformation..PPSee also window(), setViewport(), setViewXForm(), setWorldMatrix(), and setWorldXForm()..PPExamples:.)l aclock/aclock.cpp and drawdemo/drawdemo.cpp..SH "void QPainter::setWindow ( const QRect & r )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the painter's window to rectangle \fIr\fR..SH "void QPainter::setWorldMatrix ( const QWMatrix & m, bool combine = FALSE )"Sets the world transformation matrix to \fIm\fR and enables world transformation..PPIf \fIcombine\fR is TRUE, then \fIm\fR is combined with the current transformation matrix, otherwise \fIm\fR replaces the current transformation matrix..PPIf \fIm\fR is the identity matrix and \fIcombine\fR is FALSE, this function calls setWorldXForm(FALSE). (The identity matrix is the matrix where QWMatrix::m11() and QWMatrix::m22() are 1.0 and the rest are 0.0.).PPWorld transformations are applied after the view transformations (i.e. window and viewport)..PPThe following functions can transform the coordinate system without using a QWMatrix:.TPtranslate().TPscale().TPshear().TProtate().PPThey operate on the painter's worldMatrix() and are implemented like this:.PP.nf.br void QPainter::rotate( double a ).br {.br QWMatrix m;.br m.rotate( a );.br setWorldMatrix( m, TRUE );.br }.br.fi.PPNote that you should always use \fIcombine\fR when you are drawing into a QPicture. Otherwise it may not be possible to replay the picture with additional transformations. Using translate(), scale(), etc., is safe..PPFor a brief overview of coordinate transformation, see the Coordinate System Overview..PPSee also worldMatrix(), setWorldXForm(), setWindow(), setViewport(), setViewXForm(), xForm(), and QWMatrix..PPExamples:.)l drawdemo/drawdemo.cpp and xform/xform.cpp..SH "void QPainter::setWorldXForm ( bool enable )"Enables world transformations if \fIenable\fR is TRUE, or disables world transformations if \fIenable\fR is FALSE. The world transformation matrix is not changed..PPSee also setWorldMatrix(), setWindow(), setViewport(), setViewXForm(), and xForm()..SH "void QPainter::shear ( double sh, double sv )"Shears the coordinate system by \fI(sh, sv)\fR..PPSee also translate(), scale(), rotate(), resetXForm(), setWorldMatrix(), and xForm()..SH "int * QPainter::tabArray () const"Returns the currently set tab stop array..PPSee also setTabArray()..SH "int QPainter::tabStops () const"Returns the tab stop setting..PPSee also setTabStops()..SH "void QPainter::translate ( double dx, double dy )"Translates the coordinate system by \fI(dx, dy)\fR. After this call, \fI(dx, dy)\fR is added to points..PPFor example, the following code draws the same point twice:.PP.nf.br void MyWidget::paintEvent().br {.br QPainter paint( this );.br.br paint.drawPoint( 0, 0 );.br.br paint.translate( 100.0, 40.0 );.br paint.drawPoint( -100, -40 );.br }.br.fi.PPSee also scale(), shear(), rotate(), resetXForm(), setWorldMatrix(), and xForm()..PPExamples:.)l helpviewer/helpwindow.cpp, t10/cannon.cpp, t9/cannon.cpp, themes/metal.cpp, themes/wood.cpp, and xform/xform.cpp..SH "QRect QPainter::viewport () const"Returns the viewport rectangle..PPSee also setViewport() and setViewXForm()..PPExample: aclock/aclock.cpp..SH "QRect QPainter::window () const"Returns the window rectangle..PPSee also setWindow() and setViewXForm()..SH "const QWMatrix & QPainter::worldMatrix () const"Returns the world transformation matrix..PPSee also setWorldMatrix()..SH "QPoint QPainter::xForm ( const QPoint & pv ) const"Returns the point \fIpv\fR transformed from model coordinates to device coordinates..PPSee also xFormDev() and QWMatrix::map()..SH "QRect QPainter::xForm ( const QRect & rv ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the rectangle \fIrv\fR transformed from model coordinates to device coordinates..PPIf world transformation is enabled and rotation or shearing has been specified, then the bounding rectangle is returned..PPSee also xFormDev() and QWMatrix::map()..SH "QPointArray QPainter::xForm ( const QPointArray & av ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the point array \fIav\fR transformed from model coordinates to device coordinates..PPSee also xFormDev() and QWMatrix::map()..SH "QPointArray QPainter::xForm ( const QPointArray & av, int index, int npoints ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the point array \fIav\fR transformed from model coordinates to device coordinates. The \fIindex\fR is the first point in the array and \fInpoints\fR denotes the number of points to be transformed. If \fInpoints\fR is negative, all points from \fIav[index
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -