📄 qpainter.3qt
字号:
.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 QApplication::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 QApplication::style() is \fCWindowStyle).\fR.PPThe pen color used to draw the rectangle is either white or black depending on the color 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..PPNote that while you mostly don't need to call end(), the destructor will do it, there is at least one common case, namely double buffering..PP.nf.br QPainter p( myPixmap, this ).br // ....br p.end(); // stops drawing on myPixmap.br p.begin( this );.br p.drawPixmap( myPixmap );.fi.PPSince you can't draw a QPixmap while it is being painted, it is necessary to close the active painter..PPSee also begin() and isActive()..PPExamples:.(lpicture/picture.cpp desktop/desktop.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:.(lscrollview/scrollview.cpp progress/progress.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 currently set painter font..PPSee also setFont() and QFont..SH "QFontInfo QPainter::fontInfo () const"Returns the font info for the painter, if the painter is active. It is not possible to obtain font information for an inactive painter, so the return value is undefined if the painter is not active..PPSee also fontMetrics() and isActive()..SH "QFontMetrics QPainter::fontMetrics () const"Returns the font metrics for the painter, if the painter is active. It is not possible to obtain metrics for an inactive painter, so the return value is undefined if the painter is not active..PPSee also fontInfo() and isActive()..PPExamples:.(lmovies/main.cpp scrollview/scrollview.cpp drawdemo/drawdemo.cpp desktop/desktop.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 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 pen position to \fI(x,y)\fR and sets \fI(x,y)\fR to be the new current pen position..PPSee also QPen, moveTo(), drawLine() and pos()..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 pen position to \fI(x,y)\fR.PPSee also lineTo() and pos()..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 "QPoint QPainter::pos () const"Returns the current position of the pen..PPSee also moveTo()..SH "RasterOp QPainter::rasterOp () const"Returns the current raster operation..PPSee also setRasterOp() and RasterOp..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 unless \fIreplacement\fR is 0. If \fIreplacement\fR is 0, the redirection for \fIpdev\fR is removed..PPMostly, you can get better results with less work by calling QPixmap::grabWidget() or QPixmap::grapWindow()..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 ()"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPWe recommend using save() instead..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). A save() must be followed by a corresponding restore(). end() unwinds the stack()..PPSee also restore()..SH "void QPainter::saveWorldMatrix ()"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. 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()..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 one of \fCTransparentMode\fR (the default) and \fCOpaqueMode.\fR.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()..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()..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..PPExamples:.(ldrawdemo/drawdemo.cpp picture/picture.cpp forever/forever.cpp grapher/grapher.cpp desktop/desktop.cpp.)l.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 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 the the rectangle \fI(x,y,w,h)\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 setClipRegion(), clipRegion() and setClipping()..PPExamples:.(lsplitter/splitter.cpp qtimage/qtimage.cpp progress/progress.cpp grapher/grapher.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..PPIf the rectangle is invalid, the rectangle will be normalized() before the clipping region is set. This semantics will change in Qt-3 and an invalid rectangle will clip the painter to an empty rectangle..PPSee also QRect::isValid() and QRect::normalize()..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 subsequent drawText() functions. The text color is the same as the pen color..PPSee also font() and drawText()..PPExamples:.(lmovies/main.cpp scrollview/scrollview.cpp drawdemo/drawdemo.cpp picture/picture.cpp menu/menu.cpp grapher/grapher.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:.(lmovies/main.cpp scrollview/scrollview.cpp drawdemo/drawdemo.cpp drawlines/connect.cpp forever/forever.cpp progress/progress.cpp grapher/grapher.cpp desktop/desktop.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 The default is \fCCopyROP.\fR.PPSee also rasterOp()..SH "void QPainter::setTabArray ( int * ta )"Sets the tab stop array to \fIta.\fR This puts tab stops at \fIta[0],\fR ta[1] 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 ie. locates tab stops at ts, 2*ts, 3*ts and so on..PPTab stops are used when drawing formatted text with \fCExpandTabs\fR 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. 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()..SH "void QPainter::setViewport ( 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::setWindow ( int x, int y, int w, int h )"Sets the window rectangle view transformation for the painter and enables view transformation.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -