⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpainter.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 5 页
字号:
Returns the current background color..PPSee also setBackgroundColor() and QColor..SH "BGMode QPainter::backgroundMode () const"Returns the current background mode..PPSee also setBackgroundMode() and BGMode..SH "bool QPainter::begin ( const QPaintDevice * pd, bool unclipped = FALSE )"Begins painting the paint device \fIpd\fR and returns TRUE if successful, or FALSE if an error occurs. If \fIunclipped\fR is TRUE, the painting will not be clipped at the paint device's boundaries, yet note that this is not supported by all platforms..PPThe errors that can occur are serious problems, such as these:.PP.nf.br    p->begin( 0 ); // impossible - paint device cannot be 0.br.br    QPixmap pm( 0, 0 );.br    p->begin( pm ); // impossible - pm.isNull();.br.br    p->begin( myWidget );.br    p2->begin( myWidget ); // impossible - only one painter at a time.br.fi.PPNote that most of the time, you can use one of the constructors instead of begin(), and that end() is automatically done at destruction..PP\fBWarning:\fR A paint device can only be painted by one painter at a time..PPSee also end() and flush()..PPExamples:.)l aclock/aclock.cpp, application/application.cpp, desktop/desktop.cpp, hello/hello.cpp, picture/picture.cpp, t10/cannon.cpp and xform/xform.cpp..SH "bool QPainter::begin ( const QPaintDevice * pd, const QWidget * copyAttributes, bool unclipped = FALSE )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis version opens the painter on a paint device \fIpd\fR and sets the initial pen, background color and font from \fIcopyAttributes\fR, painting over the paint devices' children when \fIunclipped\fR is TRUE. This is equivalent to:.PP.nf.br    QPainter p;.br    p.begin( pd );.br    p.setPen( copyAttributes->foregroundColor() );.br    p.setBackgroundColor( copyAttributes->backgroundColor() );.br    p.setFont( copyAttributes->font() );.br.fi.PPThis begin function is convenient for double buffering. When you draw in a pixmap instead of directly in a widget (to later bitBlt the pixmap into the widget) you will need to set the widgets's font etc. This function does exactly that..PPExample:.PP.nf.br    void MyWidget::paintEvent( QPaintEvent * ).br    {.br        QPixmap pm(size());.br        QPainter p;.br        p.begin(&pm, this);.br        // ... potentially flickering paint operation ....br        p.end();.br        bitBlt(this, 0, 0, &pm);.br    }.br.fi.PPSee also end()..SH "QRect QPainter::boundingRect ( int x, int y, int w, int h, int flags, const QString &, int len = -1, QTextParag ** intern = 0 )"Returns the bounding rectangle of the aligned text that would be printed with the corresponding drawText() function using the first \fIlen\fR characters of the string if \fIlen\fR is > -1, or the whole of the string if \fIlen\fR is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle that begins at point \fI(x, y)\fR with width \fIw\fR and hight \fIh\fR..PPThe \fIflags\fR argument is the bitwise OR of the following flags:.TPAlignAuto aligns according to the language, usually left..TPAlignLeft aligns to the left border..TPAlignRight aligns to the right border..TPAlignHCenter aligns horizontally centered..TPAlignTop aligns to the top border..TPAlignBottom aligns to the bottom border..TPAlignVCenter aligns vertically centered.TPAlignCenter (== AlignHCenter | AlignVCenter).TPSingleLine ignores newline characters in the text..TPExpandTabs expands tabulators..TPShowPrefix interprets "&x" as "x" underlined..TPWordBreak 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..PPThe \fIintern\fR parameter should not be used..PPSee also Qt::TextFlags..SH "QRect QPainter::boundingRect ( const QRect & r, int flags, const QString & str, int len = -1, QTextParag ** internal = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the bounding rectangle of the aligned text that would be printed with the corresponding drawText() function using the first \fIlen\fR characters from \fIstr\fR if \fIlen\fR is > -1, or the whole of \fIstr\fR if \fIlen\fR is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle \fIr\fR..PPThe \fIinternal\fR parameter should not be used..PPSee also drawText(), fontMetrics(), QFontMetrics::boundingRect() and Qt::TextFlags..SH "const QBrush & QPainter::brush () const"Returns the current painter brush..PPSee also QPainter::setBrush()..PPExamples:.)l themes/metal.cpp and themes/wood.cpp..SH "const QPoint & QPainter::brushOrigin () const"Returns the brush origin currently set..PPSee also setBrushOrigin()..SH "void QPainter::cleanup ()\fC [static]\fR"Internal function that cleans up the painter..SH "QRegion QPainter::clipRegion ( CoordinateMode m = CoordDevice ) const"Returns the currently set clip region. Note 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(), setClipRect(), setClipping() and QPainter::CoordinateMode..PPExample: themes/wood.cpp..SH "QPaintDevice * QPainter::device () const"Returns the paint device on which this painter is currently painting, or null if the painter is not active..PPSee also QPaintDevice::paintingActive()..PPExamples:.)l helpviewer/helpwindow.cpp and listboxcombo/listboxcombo.cpp..SH "void QPainter::drawArc ( int x, int y, int w, int h, int a, int alen )"Draws an arc defined by the rectangle \fI(x, y, w, h)\fR, the start angle \fIa\fR and the arc length \fIalen\fR..PPThe angles \fIa\fR and \fIalen\fR are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of \fIa\fR and \fIalen\fR mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3'o clock position..PPExample:.PP.nf.br    QPainter p( myWidget );.br    p.drawArc( 10,10, 70,100, 100*16, 160*16 ); // draws a "(" arc.br.fi.PPSee also drawPie() and drawChord()..SH "void QPainter::drawArc ( const QRect & r, int a, int alen )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the arc that fits inside the rectangle \fIr\fR with start angle \fIa\fR and arc length \fIalen\fR..SH "void QPainter::drawChord ( int x, int y, int w, int h, int a, int alen )"Draws a chord defined by the rectangle \fI(x, y, w, h)\fR, the start angle \fIa\fR and the arc length \fIalen\fR..PPThe chord is filled with the current brush()..PPThe angles \fIa\fR and \fIalen\fR are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of \fIa\fR and \fIalen\fR mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3'o clock position..PPSee also drawArc() and drawPie()..SH "void QPainter::drawChord ( const QRect & r, int a, int alen )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws a chord that fits inside the rectangle \fIr\fR with start angle \fIa\fR and arc length \fIalen\fR..SH "void QPainter::drawConvexPolygon ( const QPointArray & pa, int index = 0, int npoints = -1 )"Draws the convex polygon defined by the \fInpoints\fR points in \fIpa\fR starting at \fIpa[index]\fR (\fIindex\fR defaults to 0)..PPIf the supplied polygon is not convex, the results are undefined..PPOn some platforms (e.g., X Window), this is faster than drawPolygon()..PPExample: aclock/aclock.cpp..SH "void QPainter::drawCubicBezier ( const QPointArray & a, int index = 0 )"Draws a cubic Bezier curve defined by the control points in \fIa\fR, starting at \fIa[index]\fR (\fIindex\fR defaults to 0)..PPControl points after \fIa[index + 3]\fR are ignored. Nothing happens if there aren't enough control points..SH "void QPainter::drawEllipse ( int x, int y, int w, int h )"Draws an ellipse with center at \fI(x + w/2, y + h/2)\fR and size \fI(w, h)\fR..PPExamples:.)l drawdemo/drawdemo.cpp, picture/picture.cpp and tictac/tictac.cpp..SH "void QPainter::drawEllipse ( const QRect & r )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the ellipse that fits inside rectangle \fIr\fR..SH "void QPainter::drawImage ( int x, int y, const QImage & image, int sx = 0, int sy = 0, int sw = -1, int sh = -1, int conversionFlags = 0 )"Draws at (\fIx\fR, \fIy\fR) the \fIsw\fR by \fIsh\fR area of pixels from (\fIsx\fR, \fIsy\fR) in \fIimage\fR, using \fIconversionFlags\fR if the image needs to be converted to a pixmap. The default value for \fIconversionFlags\fR is 0; see convertFromImage() for information about what other values do..PPThis function may convert \fIimage\fR to a pixmap and then draw it, if device() is a QPixmap or a QWidget, or else draw it directly, if device() is a QPrinter or QPicture..PPSee also drawPixmap() and QPixmap::convertFromImage()..SH "void QPainter::drawImage ( const QPoint &, const QImage &, const QRect & sr, int conversionFlags = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the rectangle \fIsr\fR from the image at the given point..SH "void QPainter::drawImage ( const QPoint & p, const QImage & i, int conversion_flags = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the image \fIi\fR at point \fIp\fR..PPIf the image needs to be modified to fit in a lower-resolution result (eg. converting from 32-bit to 8-bit), use the \fIconversion_flags\fR to specify how you'd prefer this to happen..PPSee also Qt::ImageConversionFlags..SH "void QPainter::drawImage ( const QRect & r, const QImage & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the image \fIi\fR into the rectangle \fIr\fR. The image will be scaled to fit the rectangle if image and rectangle dimensions differ..SH "void QPainter::drawLine ( int x1, int y1, int x2, int y2 )"Draws a line from (\fIx1\fR, \fIy1\fR) to (\fIx2\fR, \fIy2\fR) and sets the current pen position to (\fIx2\fR, \fIy2\fR)..PPSee also pen()..PPExamples:.)l aclock/aclock.cpp, drawlines/connect.cpp, progress/progress.cpp, splitter/splitter.cpp, themes/metal.cpp and themes/wood.cpp..SH "void QPainter::drawLine ( const QPoint & p1, const QPoint & p2 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws a line from point \fIp1\fR to point \fIp2\fR..SH "void QPainter::drawLineSegments ( const QPointArray & a, int index = 0, int nlines = -1 )"Draws \fInlines\fR separate lines from points defined in \fIa\fR, starting at a[\fIindex\fR] (\fIindex\fR defaults to 0). If \fInlines\fR is -1 (the defauls) all points until the end of the array are used (i.e. (a.size()-index)/2 lines are drawn)..PPDraws the 1st line from \fIa[index]\fR to \fIa[index+1]\fR. Draws the 2nd line from \fIa[index+2]\fR to \fIa[index+3]\fR etc..PPSee also drawPolyline(), drawPolygon() and QPen..SH "void QPainter::drawPicture ( int x, int y, const QPicture & pic )"Replays the picture \fIpic\fR translated by ( \fIx\fR, \fIy\fR )..PPThis function does exactly the same as QPicture::play() when called with (\fIx\fR, \fIy\fR) = (0, 0)..PPExamples:.)l picture/picture.cpp and xform/xform.cpp..SH "void QPainter::drawPicture ( const QPicture & pic )"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPUse one of the other QPainter::drawPicture() functions with a (0, 0) offset instead..SH "void QPainter::drawPicture ( const QPoint & p, const QPicture & pic )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws picture \fIpic\fR at point \fIp\fR..SH "void QPainter::drawPie ( int x, int y, int w, int h, int a, int alen )"Draws a pie defined by the rectangle \fI(x, y, w, h)\fR, the start angle \fIa\fR and the arc length \fIalen\fR..PPThe pie is filled with the current brush()..PPThe angles \fIa\fR and \fIalen\fR are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of \fIa\fR and \fIalen\fR mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3'o clock position..PPSee also drawArc() and drawChord()..PPExamples:.)l drawdemo/drawdemo.cpp, grapher/grapher.cpp, t10/cannon.cpp and t9/cannon.cpp..SH "void QPainter::drawPie ( const QRect & r, int a, int alen )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws a pie segment that fits inside the rectangle \fIr\fR with start angle \fIa\fR and arc length \fIalen\fR..SH "void QPainter::drawPixmap ( int x, int y, const QPixmap & pixmap, int sx = 0, int sy = 0, int sw = -1, int sh = -1 )"Draws a pixmap at \fI(x, y)\fR by copying a part of \fIpixmap\fR into the paint device..PP\fI(x, y)\fR specify the top-left point in the paint device that is to be drawn onto. \fI(sx, sy)\fR specify the top-left point in \fIpixmap\fR that is to be drawn. The default is (0, 0)..PP\fI(sw, sh)\fR specify the size of the pixmap that is to be drawn. The default, (-1, -1), means all the way to the bottom right of the pixmap..PPSee also bitBlt() and QPixmap::setMask()..PPExamples:.)l grapher/grapher.cpp, picture/picture.cpp, qdir/qdir.cpp, qtimage/qtimage.cpp, showimg/showimg.cpp, t10/cannon.cpp and xform/xform.cpp..SH "void QPainter::drawPixmap ( const QPoint & p, const QPixmap & pm, const QRect & sr )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the rectangle \fIsr\fR of pixmap \fIpm\fR with its origin at point \fIp\fR..SH "void QPainter::drawPixmap ( const QPoint & p, const QPixmap & pm )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the pixmap \fIpm\fR with its origin at point \fIp\fR..SH "void QPainter::drawPixmap ( const QRect & r, const QPixmap & pm )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the pixmap \fIpm\fR into the rectangle \fIr\fR. The pixmap is scaled to fit the rectangle, if image and rectangle size disagree..SH "void QPainter::drawPoint ( int x, int y )"Draws/plots a single point at \fI(x, y)\fR using the current pen..PPSee also QPen..PPExamples:.)l desktop/desktop.cpp and drawlines/connect.cpp..SH "void QPainter::drawPoint ( const QPoint & p )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDraws the point \fIp\fR.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -