📄 qpainter.3qt
字号:
.PPExamples:.(ldesktop/desktop.cpp picture/picture.cpp.)l.SH "void QPainter::drawPolyline ( const QPointArray & a, int index=0, int npoints=-1 )"Draws the polyline defined by the \fInpoints\fR points in \fIa\fR starting at \fIa[index].\fR.PPIf \fInpoints\fR is -1 all points until the end of the array are used (i.e. a.size()-index-1 line segments are drawn)..PPSee also: drawLineSegments() and drawPolygon()..PPExamples:.(ldrawdemo/drawdemo.cpp.)l.SH "void QPainter::drawQuadBezier ( const QPointArray & a, int index=0 )"Draws a cubic Bezier curve defined by the control points in \fIa,\fR starting at \fIa[index].\fR.PP\fIa\fR must have 4 points or more. The control point \fIa[index+4]\fR and beyond are ignored..SH "void QPainter::drawRect ( int x, int y, int w, int h )"Draws a rectangle with upper left corner at \fI(x,y)\fR and with width \fIw\fR and height \fIh.\fR.PPSee also: drawRoundRect()..PPExamples:.(lgrapher/grapher.cpp drawdemo/drawdemo.cpp forever/forever.cpp trivial/trivial.cpp picture/picture.cpp.)l.SH "void QPainter::drawRect ( const QRect & r )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawRoundRect ( int x, int y, int w, int h, int xRnd, int yRnd )"Draws a rectangle with round corners at \fI(x,y),\fR with width \fIw\fR and height \fIh.\fR.PPThe \fIxRnd\fR and \fIyRnd\fR arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness..PPThe width and height include both lines..PPSee also: drawRect()..PPExamples:.(ldrawdemo/drawdemo.cpp.)l.SH "void QPainter::drawRoundRect ( const QRect & r, int xRnd, int yRnd )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawText ( int x, int y, const QString & str, int len = -1 )"Draws at most \fIlen\fR characters from \fIstr\fR at position \fI(x,y).\fR.PP\fI(x,y)\fR is the base line position. Note that the meaning of \fIy\fR is not the same for the two drawText() varieties..SH "void QPainter::drawText ( int x, int y, int w, int h, int tf, const QString & str, int len = -1, QRect * brect=0, char ** internal=0 )"Draws at most \fIlen\fR characters from \fIstr\fR in the rectangle \fI(x,y,w,h).\fR.PPNote that the meaning of \fIy\fR is not the same for the two drawText() varieties..PPThis function draws formatted text. The \fItf\fR text formatting is the bitwise OR of the following flags: .TP\fCAlignLeft\fR aligns to the left border..TP\fCAlignRight\fR aligns to the right border..TP\fCAlignHCenter\fR aligns horizontally centered..TP\fCAlignTop\fR aligns to the top border..TP\fCAlignBottom\fR aligns to the bottom border..TP\fCAlignVCenter\fR aligns vertically centered.TP\fCAlignCenter\fR (= \fCAlignHCenter\fR | AlignVCenter).TP\fCSingleLine\fR ignores newline characters in the text..TP\fCDontClip\fR never clips the text to the rectangle..TP\fCExpandTabs\fR expands tabulators..TP\fCShowPrefix\fR displays "&x" as "x" underlined..TP\fCWordBreak\fR breaks the text to fit the rectangle..PPHorizontal alignment defaults to AlignLeft and vertical alignment defaults to AlignTop..PPIf several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined..PPIf ExpandTabs is set and no tab stops or tab array have been set tabs will expand to the closest reasonable tab stop based on the current font. For fixed pitch (fixed width) fonts you are guaranteed that each tab stop will be at a multiple of eight of the width of the characters in the font..PP\fIbrect\fR (if non-null) is set to the actual bounding rectangle of the output. \fIinternal\fR is, yes, internal..PPThese flags are defined in qnamespace.h..PPSee also: boundingRect()..PPExamples:.(lgrapher/grapher.cpp drawdemo/drawdemo.cpp progress/progress.cpp desktop/desktop.cpp scrollview/scrollview.cpp trivial/trivial.cpp movies/main.cpp picture/picture.cpp.)l.SH "void QPainter::drawText ( const QPoint & p, const QString &, int len = -1 )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawText ( const QRect & r, int tf, const QString &, int len = -1, QRect * br=0, char ** i=0 )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawTiledPixmap ( int x, int y, int w, int h, const QPixmap & pixmap, int sx=0, int sy=0 )"Draws a tiled \fIpixmap\fR in the specified rectangle..PPArguments:.TP\fI(x,y,w,h)\fR is the rectangle to be filled..TP\fI(sx,sy)\fR specify an offset in the pixmap. The pixmap is clipped if a mask has been set..PPCalling drawTiledPixmap() is similar to calling drawPixmap() several times to fill (tile) an area with a pixmap..PPSee also: drawPixmap()..SH "void QPainter::drawTiledPixmap ( const QRect & r, const QPixmap & pm )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawTiledPixmap ( const QRect & r, const QPixmap & pm, const QPoint & sp )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawWinFocusRect ( int x, int y, int w, int h )"Draws a Windows focus rectangle with upper left corner at \fI(x,y)\fR and with width \fIw\fR and height \fIh.\fR.PPThis function draws a stippled XOR rectangle that is used to indicate keyboard focus (when the GUI style is \fCWindowStyle)..PP\fBWarning:\fR\fR This function draws nothing if the coordinate system has been rotated or sheared..PPSee also: drawRect() and QApplication::style()..SH "void QPainter::drawWinFocusRect ( int x, int y, int w, int h, const QColor & bgColor )"Draws a Windows focus rectangle with upper left corner at \fI(x,y)\fR and with width \fIw\fR and height \fIh\fR using a pen color that contrasts with \fIbgColor.\fR.PPThis function draws a stippled rectangle (XOR is not used) that is used to indicate keyboard focus (when the GUI style is \fCWindowStyle).\fR.PPThe pen color used to draw the rectangle is either white or black depending on the grayness of \fIbgColor\fR (see QColor::gray())..PP\fBWarning:\fR This function draws nothing if the coordinate system has been rotated or sheared..PPSee also: drawRect() and QApplication::style()..SH "void QPainter::drawWinFocusRect ( const QRect & r )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::drawWinFocusRect ( const QRect & r, const QColor & bgColor )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "bool QPainter::end ()"Ends painting. Any resources used while painting are released..PPSee also: begin()..PPExamples:.(ldesktop/desktop.cpp picture/picture.cpp.)l.SH "void QPainter::eraseRect ( int x, int y, int w, int h )"Erases the area inside \fI(x,y,w,h).\fR Equivalent to \fCfillRect( x, y, w, h, backgroundColor() )\fR.SH "void QPainter::eraseRect ( const QRect & r )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::fillRect ( int x, int y, int w, int h, const QBrush & brush )"Fills the rectangle \fI(x,y,w,h)\fR with the \fIbrush.\fR.PPYou can specify a QColor as \fIbrush,\fR since there is a QBrush constructor that takes a QColor argument and creates a solid pattern brush..PPSee also: drawRect()..PPExamples:.(lprogress/progress.cpp scrollview/scrollview.cpp.)l.SH "void QPainter::fillRect ( const QRect & r, const QBrush & brush )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::flush ()"Flushes any buffered drawing operations..SH "const QFont & QPainter::font () const"Returns the current painter font..PPSee also: setFont() and QFont..SH "QFontInfo QPainter::fontInfo () const"Returns the font info for the painter. Font info can only be obtained when the painter is active..PPSee also: fontMetrics() and isActive()..SH "QFontMetrics QPainter::fontMetrics () const"Returns the font metrics for the painter. Font metrics can only be obtained when the painter is active..PPSee also: fontInfo() and isActive()..PPExamples:.(ldrawdemo/drawdemo.cpp desktop/desktop.cpp scrollview/scrollview.cpp movies/main.cpp.)l.SH "bool QPainter::hasClipping () const"Returns TRUE if clipping has been set, otherwise FALSE..PPSee also: setClipping()..SH "bool QPainter::hasViewXForm () const"Returns TRUE if view transformation is enabled, otherwise FALSE..PPSee also: setViewXForm() and xForm()..SH "bool QPainter::hasWorldXForm () const"Returns TRUE if world transformation is enabled, otherwise FALSE..PPSee also: setWorldXForm()..SH "void QPainter::initialize () \fC[static]\fR"Internal function that initializes the painter..SH "bool QPainter::isActive () const"Returns the TRUE if the painter is active painting, i.e. begin() has been called and end() has not yet been called..PPSee also: QPaintDevice::paintingActive()..PPExamples:.(ldesktop/desktop.cpp.)l.SH "void QPainter::lineTo ( int x, int y )"Draws a line from the current point to \fI(x,y)\fR and sets this to the new current point. Both endpoints are are drawn..PPSee also: moveTo() and drawLine()..SH "void QPainter::lineTo ( const QPoint & p )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::moveTo ( int x, int y )"Sets the current point..PPSee also: lineTo() and drawLine()..SH "void QPainter::moveTo ( const QPoint & p )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "const QPen & QPainter::pen () const"Returns the current pen for the painter..PPSee also: setPen()..PPExamples:.(lprogress/progress.cpp.)l.SH "RasterOp QPainter::rasterOp () const"Returns the raster operation currently set..PPSee also: setRasterOp()..SH "void QPainter::redirect ( QPaintDevice * pdev, QPaintDevice * replacement ) \fC[static]\fR"Redirects all paint command for a paint device \fIpdev\fR to another paint device \fIreplacement.\fR.PPA redirected paint device is reset if \fIreplacement\fR is 0..PPThe following example redirects painting of a widget to a pixmap:.PP.nf.br QPixmap pm( myWidget->width(), myWidget->height() );.br pm.fill( myWidget->backgroundColor() );.br QPainter::redirect( myWidget, &pm );.br myWidget->repaint( FALSE );.br QPainter::redirect( myWidget, 0 );.fi.SH "void QPainter::resetXForm ()"Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldMatrix(), setViewport() and setWindow().PPSee also: worldMatrix(), viewPort() and window()..SH "void QPainter::restore ()"Restores the current painter state (pops a saved state off the stack)..PPSee also: save()..SH "void QPainter::restoreWorldMatrix ()"Restores the current world matrix (pops a saved matrix off the stack)..PPSee also: saveWorldMatrix()..SH "void QPainter::rotate ( double a )"Rotates the coordinate system \fIa\fR degrees..PPSee also: translate(), scale(), shear(), resetXForm(), setWorldMatrix() and xForm()..SH "void QPainter::save ()"Saves the current painter state (pushes the state onto a stack)..PPA save() must have a corresponding restore()..PPSee also: restore()..SH "void QPainter::saveWorldMatrix ()"Saves the current world matrix (pushes the matrix onto a stack)..PPIn sane code a save() has a corresponding restoreWorldMatrix()..PPSee also: restoreWorldMatrix()..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()..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 when transparent background mode is set..PPSee also: backgroundColor() and setBackgroundMode()..SH "void QPainter::setBackgroundMode ( BGMode m )"Sets the background mode of the painter to \fIm,\fR which must be one of:.TP\fCTransparentMode\fR (default).TP\fCOpaqueMode\fR.PPTransparent mode draws stippled lines and text without setting the background pixels. Opaque mode fills these space with the current background color..PPIn order to draw a bitmap or pixmap transparently, you must use QPixmap::setMask()..PPSee also: backgroundMode() and setBackgroundColor()..PPExamples:.(lpicture/picture.cpp.)l.SH "void QPainter::setBrush ( BrushStyle style )"Sets a new painter brush with black color and the specified \fIstyle.\fR.PPSee also: brush() and QBrush..SH "void QPainter::setBrush ( const QBrush & brush )"Sets a new painter brush..PPThe brush defines how to fill shapes..PPSee also: brush()..PPExamples:.(lgrapher/grapher.cpp drawdemo/drawdemo.cpp forever/forever.cpp desktop/desktop.cpp picture/picture.cpp.)l.SH "void QPainter::setBrush ( const QColor & color )"Sets a new painter brush with the style \fCSolidPattern\fR 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 is only necessary for pattern brushes or pixmap brushes..PPSee also: brushOrigin()..SH "void QPainter::setBrushOrigin ( const QPoint & p )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::setClipRect ( int x, int y, int w, int h )"Sets the clip region to \fI(x,y,w,h)\fR and enables clipping..PPNote that the clip rectangle is given in physical device coordinates and \fInot\fR subject to any coordinate transformation..PPSee also: setClipRegion(), clipRegion() and setClipping()..PPExamples:.(lqtimage/qtimage.cpp grapher/grapher.cpp progress/progress.cpp splitter/splitter.cpp trivial/trivial.cpp.)l.SH "void QPainter::setClipRect ( const QRect & r )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QPainter::setClipRegion ( const QRegion & rgn )"Sets the clip region to \fIrgn\fR and enables clipping..PPNote that the clip region is given in physical device coordinates and \fInot\fR subject to any coordinate transformation..PPSee also: setClipRect(), clipRegion() and setClipping()..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()..SH "void QPainter::setFont ( const QFont & font )"Sets a new painter font..PPThis font is used by all subsequent drawText() functions. The text color is the same as the pen color..PPSee also: font() and drawText()..PPExamples:.(lgrapher/grapher.cpp drawdemo/drawdemo.cpp scrollview/scrollview.cpp movies/main.cpp picture/picture.cpp.)l.SH "void QPainter::setPen ( PenStyle style )"Sets a new painter pen with style \fCstyle,\fR width 0 and black color..PPSee also: pen() and QPen..PPExamples:.(lgrapher/grapher.cpp drawlines/connect.cpp drawdemo/drawdemo.cpp progress/progress.cpp forever/forever.cpp desktop/desktop.cpp scrollview/scrollview.cpp movies/main.cpp.)l.SH "void QPainter::setPen ( const QColor & color )"Sets a new painter pen with style \fCSolidLine,\fR width 0 and the specified \fIcolor.\fR.PPSee also: pen() and QPen..SH "void QPainter::setPen ( const QPen & pen )"Sets a new painter pen..PPThe pen defines how to draw lines and outlines, and it also defines the text color..PPSee also: pen()..SH "void QPainter::setRasterOp ( RasterOp r )"Sets the raster operation to \fIr.\fR.PPThe \fIr\fR parameter must be one of:.TP\fCQt::CopyROP:\fR dst = src..TP\fCQt::OrROP:\fR dst = src OR dst..TP\fCQt::XorROP:\fR dst = src XOR dst..TP\fCQt::NotAndROP:\fR dst = (NOT src) AND dst.TP\fCQt::NotCopyROP:\fR dst = NOT src.TP\fCQt::NotOrROP:\fR dst = (NOT src) OR dst.TP\fCQt::NotXorROP:\fR dst = (NOT src) XOR dst.TP\fCQt::AndROP\fR dst = src AND dst.TP\fCQt::NotROP:\fR dst = NOT dst.TP\fCQt::ClearROP:\fR dst = 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -