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

📄 qpainter.3qt

📁 tmark1.11:用于生成QT/EMBEDDED应用工程的Markfile文件
💻 3QT
📖 第 1 页 / 共 4 页
字号:
.TP\fCQt::SetROP:\fR dst = 1.TP\fCQt::NopROP:\fR dst = dst.TP\fCQt::AndNotROP:\fR dst = src AND (NOT dst).TP\fCQt::OrNotROP:\fR dst = src OR (NOT dst).TP\fCQt::NandROP:\fR dst = NOT (src AND dst).TP\fCQt::NorROP:\fR dst = NOT (src OR dst).PPSee also: rasterOp()..SH "void QPainter::setTabArray ( int * ta )"Set an array containing the tab stops..PPTab stops are used when drawing formatted text with \fCExpandTabs\fR set..PPThe last tab stop must be 0 (terminates the array)..PPNotice that setting a tab array overrides any fixed tabulator stop that is set using setTabStops()..PPSee also: tabArray(), setTabStops(), drawText() and fontMetrics()..SH "void QPainter::setTabStops ( int ts )"Set the number of pixels per tab stop to a fixed number..PPTab stops are used when drawing formatted text with \fCExpandTabs\fR set. This fixed tab stop value has lower precedence than tab array settings..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..PPThe viewport and the window are initially set to \fI(0,0,width,height),\fR where \fI(width,height)\fR is the pixel size of the paint device..PPYou can use this method to normalize the coordinate system of the painter when drawing on a part of a paint device. The following example will draw a line from the top left to the bottom right corner of a page, excluding margins:.PP.nf.br      QPrinter page;.br      int margin, pageWidth, pageHeight;.br      ....br      QPainter p( page );.br      p.setViewPort( margin, margin, pageWidth - margin, pageHeight - margin );.br      p.drawLine( 0, 0, pageWidth - 2*margin, pageHeight - 2*margin );.fi.PPThe setViewPort() method is often used in conjunction with setWindow(), as in this example:.PP.nf.br      QPainter p( myWidget );.br      p.setWindow( 0, 0, 1000, 2000 );.br      p.setViewport( 100,100, 200,200 );.br      p.drawPoint( 500, 500 );                  // draws pixel at (150,125).fi.PPThe preceding example sets up a transformation that maps the logical coordinates (0,0,1000,2000) into a (200,200) rectangle at (100,100)..PPView transformations can be combined with world transformations. World transformations are applied after the view transformations..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..PPThe window rectangle is part of the view transformation. The window specifies the logical coordinate system..PPThe window and the viewport are initially set to \fI(0,0,width,height),\fR where \fI(width,height)\fR is the pixel size of the paint device..PPYou can use this method to normalize the coordinate system of the painter. The following example will draw a vertical line, from top to bottom, at the center of a pixmap, independent of the size of the pixmap:.PP.nf.br      int width, height;.br      ....br      QPixmap icon( width, height );.br      QPainter p( icon );.br      p.setWindow( 0, 0, 100, 100 );.br      p.drawLine( 50, 0, 50, 100 );             // draw center line.fi.PPThe setWindow() method is often used in conjunction with setViewport(), as in this example:.PP.nf.br      QPainter p( myWidget );.br      p.setWindow( 0, 0, 1000, 2000 );.br      p.setViewport( 100,100, 200,200 );.br      p.drawPoint( 500, 500 );                  // draws pixel at (150,125).fi.PPThe preceding example sets up a transformation that maps the logical coordinates (0,0,1000,2000) into a (200,200) rectangle at (100,100)..PPView transformations can be combined with world transformations. World transformations are applied after the view transformations..PPSee also: window(), setViewport(), setViewXForm(), setWorldMatrix() and setWorldXForm()..PPExamples:.(ldrawdemo/drawdemo.cpp forever/forever.cpp.)l.SH "void QPainter::setWindow ( 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::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 will replace the current transformation matrix..PPWorld transformations are applied after the view transformations (i.e. window and viewport)..PPIf the matrix set is the identity matrix (m11 and m22 are 1.0 and the rest are 0.0), this function calls setWorldXForm(FALSE)..PPThe following functions can transform the coordinate system without using a QWMatrix:.TPtranslate().TPscale().TPshear().TProtate().PPThey operate on the painter's world matrix 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    }.fi.PPNote that you should always use combine when you are drawing into a QPicture. Otherwise the picture may not be completely encapsulated and cannot be replayed with additional transformations. Using the translate(), scale(), etc. functions is safe..PPFurthermore, you can easily save and restore the current world transformation matrix with the convenient functions saveWorldMatrix() and restoreWorldMatrix(), respectively. If you need to draw some top-to-bottom text at the position (x y), for instance, but everything else shall remain unrotated, you can easily achieve this with:.PP.nf.br    void MyWidget::paintEvent().br    {.br        QPainter paint( this );.br        ....br        paint.saveWorldMatrix();.br        paint.translate( x, y );.br        paint.rotate( 90 );.br        paint.drawText( 0, 0, "top-to-bottom text" );.br        paint.restoreWorldMatrix();.br        .....br    }.fi.PPSee the QWMatrix documentation for a general discussion on coordinate system transformations..PPSee also: worldMatrix(), setWorldXForm(), setWindow(), setViewport(), setViewXForm() and xForm()..PPExamples:.(ldrawdemo/drawdemo.cpp.)l.SH "void QPainter::setWorldXForm ( bool enable )"Enables world transformations if \fIenable\fR is TRUE, or disables world transformations if \fIenable\fR is FALSE..PPSee also: setWorldMatrix(), setWindow(), setViewport(), setViewXForm() and xForm()..SH "void QPainter::shear ( double sh, double sv )"Shears the coordinate system \fI(sh,sv).\fR.PPSee also: translate(), scale(), rotate(), resetXForm(), setWorldMatrix() and xForm()..SH "int * QPainter::tabArray () const"Returns the tab stop array currently set..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.PPFor example, the following code draws a single vertical line 20 pixels high..PP.nf.br    void MyWidget::paintEvent().br    {.br        QPainter paint( this );.br        paint.drawLine(10,0,10,20);.br        paint.translate(100.0,100.0);.br        paint.drawLine(-90,-80,-90,-70);.br    }.fi.PPSee also: scale(), shear(), rotate(), resetXForm(), setWorldMatrix() and xForm()..SH "QRect QPainter::viewport () const"Returns the viewport rectangle..PPSee also: setViewport() and setViewXForm()..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 user coordinates to device coordinates..PPSee also: xFormDev() and QWMatrix::xForm()..SH "QPointArray QPainter::xForm ( const QPointArray & av ) const"Returns the point array \fIav\fR transformed from user coordinates to device coordinates..PPSee also: xFormDev() and QWMatrix::xForm()..SH "QPointArray QPainter::xForm ( const QPointArray & av, int index, int npoints ) const"Returns the point array \fIav\fR transformed from user 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]\fR until the last point in the array are transformed..PPThe returned point array consists of the number of points that were transformed..PPExample:.PP.nf.br    QPointArray a(10);.br    QPointArray b;.br    b = painter.xForm(a,2,4);   // b.size() == 4.br    b = painter.xForm(a,2,-1);  // b.size() == 8.fi.PPSee also: xFormDev() and QWMatrix::xForm()..SH "QRect QPainter::xForm ( const QRect & rv ) const"Returns the rectangle \fIrv\fR transformed from user 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::xForm()..SH "QPoint QPainter::xFormDev ( const QPoint & pd ) const"Returns the point \fIpv\fR transformed from device coordinates to user coordinates..PPSee also: xForm() and QWMatrix::xForm()..SH "QPointArray QPainter::xFormDev ( const QPointArray & ad ) const"Returns the point array \fIav\fR transformed from device coordinates to user coordinates..PPSee also: xForm() and QWMatrix::xForm()..SH "QPointArray QPainter::xFormDev ( const QPointArray & ad, int index, int npoints ) const"Returns the point array \fIad\fR transformed from device coordinates to user 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]\fR until the last point in the array are transformed..PPThe returned point array consists of the number of points that were transformed..PPExample:.PP.nf.br    QPointArray a(10);.br    QPointArray b;.br    b = painter.xFormDev(a,1,3);        // b.size() == 3.br    b = painter.xFormDev(a,1,-1);       // b.size() == 9.fi.PPSee also: xForm() and QWMatrix::xForm()..SH "QRect QPainter::xFormDev ( const QRect & rd ) const"Returns the rectangle \fIrv\fR transformed from device coordinates to user coordinates..PPIf world transformation is enabled and rotation or shearing is used, then the bounding rectangle is returned..PPSee also: xForm() and QWMatrix::xForm()..SH RELATED FUNCTION DOCUMENTATION.SH "void qDrawPlainRect (QPainter * p, int x, int y, int w, int h, const QColor & c, int lineWidth, const QBrush * fill)"Draws a plain rectangle given by \fI(x,y,w,h)\fR using the painter \fIp.\fR.PPThe color argument \fIc\fR specifies the line color..PPThe \fIlineWidth\fR argument specifies the line width..PPThe rectangle interior is filled with the \fI*fill\fR brush unless \fIfill\fR is null..PPIf you want to use a QFrame widget instead, you can make it display a shaded rectangle, for example \fCQFrame::setFrameStyle( QFrame::Box | QFrame::Plain )\fR..PPSee also: qDrawShadeRect()..SH "void qDrawShadeLine (QPainter * p, int x1, int y1, int x2, int y2, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth)"Draws a horizontal (\fIy1\fR == \fIy2)\fR or vertical (\fIx1\fR == \fIx2)\fR shaded line using the painter \fIp.\fR.PPNothing is drawn if \fIy1\fR != y2 and \fIx1\fR != x2 (i.e. the line is neither horizontal nor vertical)..PPThe color group argument \fIg\fR specifies the shading colors (light, dark and middle colors)..PPThe line appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE..PPThe \fIlineWidth\fR argument specifies the line width for each of the lines. It is not the total line width..PPThe \fImidLineWidth\fR argument specifies the width of a middle line drawn in the QColorGroup::mid() color..PPIf you want to use a QFrame widget instead, you can make it display a shaded line, for example \fCQFrame::setFrameStyle( QFrame::HLine | QFrame::Sunken )\fR..PPSee also: qDrawShadeRect() and qDrawShadePanel()..SH "void qDrawWinButton (QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, const QBrush * fill)"Draws a Windows-style button given by \fI(x,y,w,h)\fR using the painter \fIp.\fR.PPThe color group argument \fIg\fR specifies the shading colors (light, dark and middle colors)..PPThe button appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE..PPThe line width is 2 pixels..PPThe button interior is filled with the \fI*fill\fR brush unless \fIfill\fR is null..PPSee also: qDrawWinPanel()..SH "void qDrawWinPanel (QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, const QBrush * fill)"Draws a Windows-style panel given by \fI(x,y,w,h)\fR using the painter \fIp.\fR.PPThe color group argument \fIg\fR specifies the shading colors..PPThe panel appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE..PPThe line width is 2 pixels..PPThe button interior is filled with the \fI*fill\fR brush unless \fIfill\fR is null..PPIf you want to use a QFrame widget instead, you can make it display a shaded panel, for example \fCQFrame::setFrameStyle( QFrame::WinPanel | QFrame::Raised )\fR..PPSee also: qDrawShadePanel() and qDrawWinButton()..SH "void qDrawShadePanel (QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, const QBrush * fill)"Draws a shaded panel given by \fI(x,y,w,h)\fR using the painter \fIp.\fR.PPThe color group argument \fIg\fR specifies the shading colors (light, dark and middle colors)..PPThe panel appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE..PPThe \fIlineWidth\fR argument specifies the line width..PPThe panel interior is filled with the \fI*fill\fR brush unless \fIfill\fR is null..PPIf you want to use a QFrame widget instead, you can make it display a shaded panel, for example \fCQFrame::setFrameStyle( QFrame::Panel | QFrame::Sunken )\fR..PPSee also: qDrawWinPanel(), qDrawShadeLine() and qDrawShadeRect()..SH "void qDrawShadeRect (QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth, const QBrush * fill)"Draws a shaded rectangle/box given by \fI(x,y,w,h)\fR using the painter \fIp.\fR.PPThe color group argument \fIg\fR specifies the shading colors (light, dark and middle colors)..PPThe rectangle appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE..PPThe \fIlineWidth\fR argument specifies the line width for each of the lines. It is not the total line width..PPThe \fImidLineWidth\fR argument specifies the width of a middle line drawn in the QColorGroup::mid() color..PPThe rectangle interior is filled with the \fI*fill\fR brush unless \fIfill\fR is null..PPIf you want to use a QFrame widget instead, you can make it display a shaded rectangle, for example \fCQFrame::setFrameStyle( QFrame::Box | QFrame::Raised )\fR..PPSee also:  qDrawShadeLine(), qDrawShadePanel() and qDrawPlainRect()..SH "SEE ALSO".BR http://www.troll.no/qt/qpainter.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS.  See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

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