{"id":107082,"date":"2026-09-18T23:08:33","date_gmt":"2026-09-18T15:08:33","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/107082.html"},"modified":"2026-09-18T23:08:33","modified_gmt":"2026-09-18T15:08:33","slug":"qt-qpainter-2d-%e7%bb%98%e5%9b%be%e7%b3%bb%e7%bb%9f%e6%b7%b1%e5%ba%a6%e8%a7%a3%e6%9e%90%ef%bc%9a%e4%bb%8e%e7%94%bb%e7%ac%94%e5%88%b0%e6%b8%b2%e6%9f%93%e5%bc%95%e6%93%8e%e9%80%82","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/107082.html","title":{"rendered":"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002"},"content":{"rendered":"<h2 id=\"qt-qpainter-2d-\u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\">1. \u80cc\u666f<\/h2>\n<p>Qt \u7684 2D \u6e32\u67d3\u4f53\u7cfb\u81ea\u5e95\u5411\u4e0a\u5927\u81f4\u5206\u4e3a\u4e09\u5c42&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>\u5c42\u7ea7\u7ec4\u4ef6\u5b9a\u4f4d<\/tr>\n<tr>\n<td>\u5e95\u5c42\u6e32\u67d3\u540e\u7aef<\/td>\n<td>QPainter &#043; QPaintDevice<\/td>\n<td>\u76f4\u63a5\u7ed8\u5236 2D \u56fe\u5143&#xff08;\u7ebf\u3001\u77e9\u5f62\u3001\u692d\u5706\u3001\u8def\u5f84\u3001\u6587\u5b57\u3001\u56fe\u50cf&#xff09;\u5230\u4efb\u610f\u53ef\u7ed8\u8868\u9762<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d\u95f4\u573a\u666f\u5c42<\/td>\n<td>QGraphicsView \/ QGraphicsScene \/ QGraphicsItem<\/td>\n<td>\u5728 QPainter \u4e4b\u4e0a\u5c01\u88c5\u573a\u666f-\u89c6\u56fe-\u56fe\u5143\u67b6\u6784&#xff0c;\u63d0\u4f9b\u5bf9\u8c61\u5316\u7ba1\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u4e0a\u5c42\u58f0\u660e\u5f0f UI<\/td>\n<td>QML \/ Qt Quick&#xff08;Scene Graph&#xff09;<\/td>\n<td>\u58f0\u660e\u5f0f\u8bed\u8a00\u63cf\u8ff0\u754c\u9762&#xff0c;\u5e95\u5c42\u7528 GPU \u52a0\u901f\u7684\u573a\u666f\u56fe\u6e32\u67d3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e3a\u4ec0\u4e48\u8fd8\u9700\u8981 QPainter&#xff1f;<\/p>\n<ul>\n<li>\u81ea\u5b9a\u4e49\u63a7\u4ef6&#xff08;QWidget \u5b50\u7c7b&#xff09;\u91cd\u5199\u00a0paintEvent\u00a0\u65f6&#xff0c;\u5b98\u65b9\u63a8\u8350\u65b9\u5f0f\u5c31\u662f QPainter&#xff1b;<\/li>\n<li>\u77e2\u91cf\u56fe\u5143\u3001\u7edf\u8ba1\u56fe\u3001\u6ce2\u5f62\u3001\u753b\u677f\u3001\u6d41\u7a0b\u56fe\u7b49&#034;\u81ea\u7531\u753b\u5e03&#034;\u573a\u666f&#xff0c;QPainter \u662f\u6700\u76f4\u63a5\u3001\u53ef\u9884\u6d4b\u7684 API&#xff1b;<\/li>\n<li>QGraphicsView\u3001QCustomPlot\u3001Qwt \u7b49\u4e0a\u5c42\u6846\u67b6&#xff0c;\u5185\u90e8\u6700\u7ec8\u90fd\u843d\u5230 QPainter \u7684 draw \u7cfb\u5217\u8c03\u7528&#xff1b;<\/li>\n<li>\u79bb\u5c4f\u6e32\u67d3&#xff08;\u628a\u753b\u9762\u753b\u5230 QImage\/QPixmap \u518d\u590d\u7528&#xff09;\u662f\u9ad8\u9891\u6027\u80fd\u4f18\u5316\u624b\u6bb5\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"2-\u6838\u5fc3-api-\u8bf4\u660e\">2. \u6838\u5fc3 API \u8bf4\u660e<\/h3>\n<h4 id=\"21-qpainter-\u751f\u547d\u5468\u671f\">2.1 QPainter \u751f\u547d\u5468\u671f<\/h4>\n<p>\/\/ \u65b9\u5f0f\u4e00&#xff1a;\u6808\u4e0a\u6784\u9020\u5373 begin&#xff08;\u5e38\u7528&#xff09;<br \/>\nvoid Widget::paintEvent(QPaintEvent*) {<br \/>\n    QPainter painter(this);       \/\/ \u81ea\u52a8 begin(this)<br \/>\n    \/\/ &#8230; \u7ed8\u5236<br \/>\n}                                 \/\/ \u6790\u6784\u81ea\u52a8 end()<\/p>\n<p>\/\/ \u65b9\u5f0f\u4e8c&#xff1a;\u663e\u5f0f begin\/end&#xff08;\u7ed8\u5236\u5230\u975e QWidget \u8868\u9762\u6216\u4e2d\u9014\u5207\u6362\u8bbe\u5907\u65f6&#xff09;<br \/>\nQPainter painter;<br \/>\npainter.begin(&amp;image);<br \/>\n\/\/ &#8230;<br \/>\npainter.end();<\/p>\n<p>\u5173\u952e\u6210\u5458&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>API\u8bf4\u660e<\/tr>\n<tr>\n<td>begin(QPaintDevice*)<\/td>\n<td>\u5f00\u59cb\u7ed8\u5236&#xff0c;\u8fd4\u56de bool&#xff08;\u8bbe\u5907\u4e0d\u652f\u6301\u65f6 false&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>end()<\/td>\n<td>\u7ed3\u675f\u7ed8\u5236&#xff1b;\u672a\u663e\u5f0f\u8c03\u7528\u65f6\u6790\u6784\u51fd\u6570\u81ea\u52a8\u8c03\u7528<\/td>\n<\/tr>\n<tr>\n<td>isActive()<\/td>\n<td>\u662f\u5426\u5904\u4e8e begin \u4e4b\u540e end \u4e4b\u524d<\/td>\n<\/tr>\n<tr>\n<td>device()<\/td>\n<td>\u5f53\u524d\u7ed8\u5236\u76ee\u6807\u8bbe\u5907<\/td>\n<\/tr>\n<tr>\n<td>setRenderHint(QPainter::RenderHint, bool)<\/td>\n<td>\u8bbe\u7f6e\u6e32\u67d3\u63d0\u793a&#xff0c;\u5982\u00a0Antialiasing&#xff08;\u6297\u952f\u9f7f&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"22-qpen\u753b\u7b14\u8f6e\u5ed3\">2.2 QPen&#xff08;\u753b\u7b14&#xff1a;\u8f6e\u5ed3&#xff09;<\/h4>\n<p>QPen pen;<br \/>\npen.setColor(QColor(220, 80, 80));<br \/>\npen.setWidth(2);              \/\/ \u50cf\u7d20\u5bbd\u5ea6&#xff08;\u903b\u8f91\u5355\u4f4d&#xff0c;\u53d7\u53d8\u6362\u5f71\u54cd&#xff09;<br \/>\npen.setWidthF(1.5);           \/\/ \u6d6e\u70b9\u5bbd\u5ea6<br \/>\npen.setStyle(Qt::DashLine);   \/\/ \u7ebf\u578b&#xff1a;SolidLine\/DashLine\/DotLine\/DashDotLine&#8230;<br \/>\npen.setCapStyle(Qt::RoundCap);    \/\/ \u7aef\u70b9\u5e3d&#xff1a;FlatCap\/SquareCap\/RoundCap<br \/>\npen.setJoinStyle(Qt::RoundJoin);  \/\/ \u8fde\u63a5\u70b9&#xff1a;BevelJoin\/MiterJoin\/RoundJoin<br \/>\npainter.setPen(pen);<\/p>\n<p>painter.setPen(QPen(Qt::blue, 0)); \/\/ \u5bbd\u5ea6 0 &#061; cosmetic \u7b14&#xff08;\u59cb\u7ec8 1 \u50cf\u7d20&#xff0c;\u4e0d\u968f\u7f29\u653e\u53d8\u7c97&#xff09;<br \/>\npainter.setPen(Qt::NoPen);         \/\/ \u4e0d\u753b\u8f6e\u5ed3<\/p>\n<h4 id=\"23-qbrush\u753b\u5237\u586b\u5145\">2.3 QBrush&#xff08;\u753b\u5237&#xff1a;\u586b\u5145&#xff09;<\/h4>\n<p>painter.setBrush(QBrush(QColor(100, 200, 150)));        \/\/ \u7eaf\u8272<br \/>\npainter.setBrush(Qt::BDiagPattern);                     \/\/ \u9884\u5b9a\u4e49\u56fe\u6848<br \/>\npainter.setBrush(QBrush(QPixmap(&#034;texture.png&#034;)));       \/\/ \u7eb9\u7406\u586b\u5145<br \/>\npainter.setBrush(Qt::NoBrush);                          \/\/ \u4e0d\u586b\u5145<\/p>\n<p>\/\/ \u6e10\u53d8\u753b\u5237&#xff08;\u89c1 2.6&#xff09;<br \/>\nQLinearGradient grad(0, 0, 200, 200);<br \/>\ngrad.setColorAt(0.0, Qt::white);<br \/>\ngrad.setColorAt(1.0, QColor(40, 120, 200));<br \/>\npainter.setBrush(QBrush(grad));<\/p>\n<h4 id=\"24-draw-\u7cfb\u5217\u56fe\u5143-api\">2.4 draw \u7cfb\u5217\u56fe\u5143 API<\/h4>\n<table>\n<tbody>\n<tr>API\u4f5c\u7528<\/tr>\n<tr>\n<td>drawPoint \/ drawPoints<\/td>\n<td>\u70b9<\/td>\n<\/tr>\n<tr>\n<td>drawLine \/ drawLines \/ drawPolyline<\/td>\n<td>\u7ebf \/ \u6298\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>drawRect \/ drawRoundedRect<\/td>\n<td>\u77e9\u5f62 \/ \u5706\u89d2\u77e9\u5f62<\/td>\n<\/tr>\n<tr>\n<td>drawEllipse \/ drawArc \/ drawChord \/ drawPie<\/td>\n<td>\u692d\u5706 \/ \u5f27 \/ \u5f13\u5f62 \/ \u6247\u5f62<\/td>\n<\/tr>\n<tr>\n<td>drawPolygon<\/td>\n<td>\u591a\u8fb9\u5f62&#xff08;\u81ea\u52a8\u95ed\u5408&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>drawPath(QPainterPath)<\/td>\n<td>\u4efb\u610f\u8def\u5f84&#xff08;\u89c1 2.5&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>drawText(QRect, int flags, QString)<\/td>\n<td>\u6587\u672c&#xff08;\u89c1 2.7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>drawPixmap \/ drawImage<\/td>\n<td>\u56fe\u50cf&#xff08;\u89c1 2.8&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>fillRect(QRect, QBrush\/QColor)<\/td>\n<td>\u76f4\u63a5\u586b\u5145\u77e9\u5f62&#xff08;\u4e0d\u8d70 pen&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>eraseRect<\/td>\n<td>\u64e6\u9664&#xff08;\u4e0d\u63a8\u8350&#xff0c;\u7528 fillRect \u66ff\u4ee3&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6240\u6709 draw \u5747\u540c\u65f6\u53d7\u5f53\u524d pen&#xff08;\u8f6e\u5ed3&#xff09;\u4e0e brush&#xff08;\u586b\u5145&#xff09;\u5f71\u54cd\u3002<\/p>\n<h4 id=\"25-qpainterpath\u8def\u5f84\">2.5 QPainterPath&#xff08;\u8def\u5f84&#xff09;<\/h4>\n<p>QPainterPath path;<br \/>\npath.moveTo(50, 50);          \/\/ \u79fb\u52a8\u8d77\u70b9<br \/>\npath.lineTo(150, 50);         \/\/ \u76f4\u7ebf<br \/>\npath.quadTo(200, 0, 250, 80); \/\/ \u4e8c\u6b21\u8d1d\u585e\u5c14<br \/>\npath.cubicTo(300, 160, 100, 200, 80, 120); \/\/ \u4e09\u6b21\u8d1d\u585e\u5c14<br \/>\npath.arcTo(QRectF(20, 20, 100, 100), 0, 180); \/\/ \u5706\u5f27<br \/>\npath.closeSubpath();          \/\/ \u95ed\u5408\u5f53\u524d\u5b50\u8def\u5f84<\/p>\n<p>path.addRect(&#8230;);            \/\/ \u6dfb\u52a0\u5b50\u8def\u5f84<br \/>\npath.addEllipse(&#8230;);<br \/>\npath.addRoundedRect(&#8230;);<br \/>\npath.addText(QPointF, font, &#034;Qt&#034;);<\/p>\n<p>painter.drawPath(path);<\/p>\n<p>\/\/ \u5e38\u7528\u8c13\u8bcd<br \/>\npath.isEmpty(); path.contains(QPointF); path.boundingRect();<br \/>\n\/\/ \u5e03\u5c14\u8fd0\u7b97&#xff08;Qt 5.10&#043; \u9700\u8981 QtGui \u9644\u52a0\u6a21\u5757\u8def\u5f84\u652f\u6301&#xff09;<br \/>\nQPainterPath united &#061; path1.united(path2);   \/\/ \u5e76\u96c6<br \/>\nQPainterPath inter  &#061; path1.intersected(path2); \/\/ \u4ea4\u96c6<br \/>\nQPainterPath diff   &#061; path1.subtracted(path2);   \/\/ \u5dee\u96c6<\/p>\n<h4 id=\"26-qgradient\u6e10\u53d8\">2.6 QGradient&#xff08;\u6e10\u53d8&#xff09;<\/h4>\n<p>\u4e09\u79cd\u5185\u7f6e\u6e10\u53d8 &#043; \u4e00\u4e2a\u901a\u7528\u57fa\u7c7b&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>\u7c7b\u578b\u6784\u9020\u8981\u70b9\u793a\u4f8b<\/tr>\n<tr>\n<td>QLinearGradient(x1,y1,x2,y2)<\/td>\n<td>\u8d77\u70b9\/\u7ec8\u70b9\u5b9a\u4e49\u65b9\u5411<\/td>\n<td>\u9ad8\u5149\u3001\u8fdb\u5ea6\u6761<\/td>\n<\/tr>\n<tr>\n<td>QRadialGradient(cx,cy,r)<\/td>\n<td>\u5706\u5fc3&#043;\u534a\u5f84<\/td>\n<td>\u5149\u6655\u3001\u7403\u4f53<\/td>\n<\/tr>\n<tr>\n<td>QConicalGradient(cx,cy,angle)<\/td>\n<td>\u5706\u5fc3&#043;\u8d77\u59cb\u89d2<\/td>\n<td>\u4eea\u8868\u76d8\u3001\u8c03\u8272\u73af<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>QLinearGradient g(0, 0, width(), 0);   \/\/ \u6c34\u5e73\u6e10\u53d8<br \/>\ng.setColorAt(0.0, QColor(255, 0, 0));<br \/>\ng.setColorAt(0.5, QColor(0, 255, 0));<br \/>\ng.setColorAt(1.0, QColor(0, 0, 255));<br \/>\ng.setSpread(QGradient::RepeatSpread);  \/\/ \u8d85\u51fa\u8303\u56f4\u540e\u7684\u6269\u6563\u65b9\u5f0f<br \/>\npainter.setBrush(g);<\/p>\n<h4 id=\"27-\u6587\u5b57\u7ed8\u5236\">2.7 \u6587\u5b57\u7ed8\u5236<\/h4>\n<p>QFont font(&#034;Microsoft YaHei&#034;, 12);   \/\/ \u6ce8\u610f\u5b57\u4f53\u540d\u8981\u5b58\u5728\u4e8e\u7cfb\u7edf<br \/>\nfont.setBold(true);<br \/>\npainter.setFont(font);<br \/>\npainter.setPen(Qt::black);<\/p>\n<p>painter.drawText(QPoint(10, 30), &#034;\u5de6\u4e0a\u89d2\u57fa\u7ebf\u6587\u672c&#034;);<\/p>\n<p>painter.drawText(rect, Qt::AlignCenter | Qt::TextWordWrap, &#034;\u5c45\u4e2d\u6362\u884c\u6587\u672c&#034;);<br \/>\n\/\/ \u8fd4\u56de\u5b9e\u9645\u7ed8\u5236\u5230\u7684\u77e9\u5f62&#xff08;\u53ef\u7528\u6765\u6d4b\u6587\u672c\u5c3a\u5bf8&#xff09;<br \/>\nQRectF br;<br \/>\npainter.drawText(rect, Qt::AlignCenter, &#034;\u6587\u672c&#034;, &amp;br);<\/p>\n<p>QFontMetrics fm(painter.font());     \/\/ \u5b57\u4f53\u5ea6\u91cf<br \/>\nint w &#061; fm.horizontalAdvance(&#034;\u6587\u672c&#034;); \/\/ \u6587\u672c\u50cf\u7d20\u5bbd\u5ea6&#xff08;Qt5.11&#043;&#xff1b;\u65e7\u7248\u7528 width()&#xff09;<br \/>\nint h &#061; fm.height();                  \/\/ \u884c\u9ad8<\/p>\n<h4 id=\"28-\u56fe\u50cf\u7ed8\u5236\">2.8 \u56fe\u50cf\u7ed8\u5236<\/h4>\n<p>painter.drawPixmap(x, y, pixmap);                    \/\/ \u539f\u5c3a\u5bf8<br \/>\npainter.drawPixmap(QRect(x,y,w,h), pixmap);          \/\/ \u62c9\u4f38\u5230\u76ee\u6807\u77e9\u5f62<br \/>\npainter.drawPixmap(QRect(x,y,w,h), pixmap, QRectF(src)); \/\/ \u5e26\u6e90\u533a\u57df\u622a\u53d6<br \/>\npainter.drawImage(QRect(x,y,w,h), image);            \/\/ QImage \u540c\u7406<\/p>\n<p>\/\/ \u5e73\u6ed1\u7f29\u653e<br \/>\npainter.setRenderHint(QPainter::SmoothPixmapTransform, true);<\/p>\n<h4 id=\"29-\u5750\u6807\u7cfb\u7edf\u4e0e\u53d8\u6362\">2.9 \u5750\u6807\u7cfb\u7edf\u4e0e\u53d8\u6362<\/h4>\n<p>QPainter \u9ed8\u8ba4\u5750\u6807\u7cfb&#xff1a;\u539f\u70b9\u5728\u8bbe\u5907\u5de6\u4e0a\u89d2&#xff0c;x \u5411\u53f3&#xff0c;y \u5411\u4e0b&#xff0c;\u5355\u4f4d\u662f\u903b\u8f91\u50cf\u7d20\u3002<\/p>\n<p>painter.translate(100, 50);   \/\/ \u5e73\u79fb<br \/>\npainter.rotate(45);           \/\/ \u65cb\u8f6c&#xff08;\u5ea6&#xff0c;\u987a\u65f6\u9488&#xff09;<br \/>\npainter.scale(2.0, 2.0);      \/\/ \u7f29\u653e<br \/>\npainter.shear(0.1, 0);        \/\/ \u9519\u5207<\/p>\n<p>\/\/ \u5fc5\u987b\u6210\u5bf9\u4f7f\u7528&#xff0c;\u5426\u5219\u53d8\u6362\u53e0\u52a0\u6c61\u67d3\u540e\u7eed\u7ed8\u5236<br \/>\npainter.save();<br \/>\npainter.translate(cx, cy);<br \/>\npainter.rotate(angle);<br \/>\npainter.drawText(QPointF(0, -10), &#034;\u6807\u7b7e&#034;);<br \/>\npainter.restore();<\/p>\n<p>\/\/ \u4e16\u754c\u53d8\u6362\u77e9\u9635&#xff08;Qt 5.14&#043; \u63d0\u4f9b\u66f4\u7cbe\u786e\u7684 QTransform \u91cd\u8f7d&#xff09;<br \/>\nQTransform t;<br \/>\nt.translate(50, 50).rotate(30).scale(1.5, 1.5);<br \/>\npainter.setWorldTransform(t);<br \/>\npainter.resetTransform();     \/\/ \u91cd\u7f6e\u4e3a\u5355\u4f4d\u77e9\u9635<\/p>\n<p>\u89c6\u56fe\u53d8\u6362&#xff08;Qt 5.14&#043;&#xff09;&#xff1a;setViewport\u00a0\/\u00a0setWindow\u00a0\u5141\u8bb8\u628a\u903b\u8f91\u7a97\u53e3\u6620\u5c04\u5230\u8bbe\u5907\u89c6\u53e3&#xff0c;\u9002\u5408\u56fa\u5b9a\u903b\u8f91\u5750\u6807\u7cfb\u7684\u7ed8\u56fe&#xff08;\u5982\u66f2\u7ebf\u56fe y \u8f74\u8303\u56f4\u56fa\u5b9a&#xff09;&#xff1a;<\/p>\n<p>painter.setWindow(QRect(0, 0, 1000, 500));   \/\/ \u903b\u8f91\u7a97\u53e3<br \/>\npainter.setViewport(QRect(0, 0, width(), height())); \/\/ \u7269\u7406\u533a\u57df<br \/>\n\/\/ \u6b64\u540e\u6240\u6709\u5750\u6807\u6309 1000&#215;500 \u903b\u8f91\u7a7a\u95f4\u4e66\u5199&#xff0c;\u81ea\u52a8\u6620\u5c04<\/p>\n<h4 id=\"210-\u79bb\u5c4f\u6e32\u67d3\u4e0e\u7f13\u5b58\">2.10 \u79bb\u5c4f\u6e32\u67d3\u4e0e\u7f13\u5b58<\/h4>\n<p>\/\/ \u5e38\u7528\u7f13\u5b58\u8f7d\u4f53<br \/>\nQPixmap  pm(size);            \/\/ \u5c4f\u5e55\u4f18\u5316&#xff0c;\u7ed8\u5236\u5728\u5c4f\u5e55\u5173\u8054\u8bbe\u5907\u4e0a\u6700\u5feb&#xff08;\u4f9d\u8d56\u5e73\u53f0&#xff09;<br \/>\nQImage   img(size, QImage::Format_ARGB32_Premultiplied); \/\/ \u50cf\u7d20\u53ef\u76f4\u8bfb&#xff0c;\u9002\u5408 CPU \u5904\u7406\/\u4fdd\u5b58<br \/>\nQPicture pic;                 \/\/ \u8bb0\u5f55\u7ed8\u5236\u6307\u4ee4&#xff08;\u77e2\u91cf&#xff09;&#xff0c;\u53ef\u91cd\u653e<\/p>\n<p>\/\/ \u79bb\u5c4f\u7ed8\u5236\u6807\u51c6\u59ff\u52bf<br \/>\nQPixmap pm(size);<br \/>\npm.fill(Qt::transparent);     \/\/ \u5148\u586b\u5145\u900f\u660e&#xff0c;\u5426\u5219\u521d\u59cb\u5185\u5bb9\u672a\u5b9a\u4e49<br \/>\nQPainter p(&amp;pm);<br \/>\np.setRenderHint(QPainter::Antialiasing);<br \/>\n\/\/ &#8230; \u7ed8\u5236<br \/>\np.end();<\/p>\n<p>\/\/ \u4e4b\u540e\u5728 paintEvent \u4e2d blit \u4e0a\u5c4f<br \/>\npainter.drawPixmap(0, 0, pm);<\/p>\n<p>\/\/ QImage \u9010\u50cf\u7d20\u5904\u7406\u793a\u4f8b<br \/>\nQImage img(400, 300, QImage::Format_ARGB32_Premultiplied);<br \/>\nimg.fill(Qt::white);<br \/>\nfor (int y &#061; 0; y &lt; img.height(); &#043;&#043;y)<br \/>\n    for (int x &#061; 0; x &lt; img.width(); &#043;&#043;x)<br \/>\n        img.setPixelColor(x, y, QColor(x % 256, y % 256, 128));<br \/>\nimg.save(&#034;out.png&#034;);          \/\/ \u652f\u6301 png\/jpg\/bmp \u7b49&#xff08;\u6309\u540e\u7f00\u9009\u683c\u5f0f&#xff09;<\/p>\n<h4 id=\"211-\u7ec4\u5408\u6a21\u5f0fcomposition-modeqt-46\">2.11 \u7ec4\u5408\u6a21\u5f0f&#xff08;Composition Mode&#xff0c;Qt 4.6&#043;&#xff09;<\/h4>\n<p>painter.setCompositionMode(QPainter::CompositionMode_SourceOver); \/\/ \u9ed8\u8ba4<br \/>\npainter.setCompositionMode(QPainter::CompositionMode_Source);     \/\/ \u76f4\u63a5\u8986\u76d6<br \/>\npainter.setCompositionMode(QPainter::CompositionMode_Plus);       \/\/ \u53e0\u52a0\u589e\u4eae<br \/>\npainter.setCompositionMode(QPainter::CompositionMode_DestinationOver);<br \/>\n\/\/ &#8230; \u5171 30 \u79cd\u6a21\u5f0f&#xff0c;\u9002\u5408\u5b9e\u73b0\u6a61\u76ae\u64e6\u3001\u53d1\u5149\u3001\u906e\u7f69\u7b49\u6548\u679c<br \/>\n\/\/ \u6a61\u76ae\u64e6\u5e38\u7528&#xff1a;\u5148\u8bbe\u7f6e Source \u6a21\u5f0f&#xff0c;\u518d\u7528\u900f\u660e\u8272\u7ed8\u5236<br \/>\npainter.setCompositionMode(QPainter::CompositionMode_Clear);<br \/>\npainter.fillRect(rect, Qt::transparent);<br \/>\npainter.setCompositionMode(QPainter::CompositionMode_SourceOver);<\/p>\n<hr \/>\n<h3 id=\"3-\u8be6\u7ec6\u4f7f\u7528\u8bf4\u660e\">3. \u8be6\u7ec6\u4f7f\u7528\u8bf4\u660e<\/h3>\n<h4 id=\"31-\u6700\u5c0f\u53ef\u8fd0\u884c\u793a\u4f8b\u5e26\u6e10\u53d8\u4e0e\u6297\u952f\u9f7f\u7684\u81ea\u5b9a\u4e49\u63a7\u4ef6\">3.1 \u6700\u5c0f\u53ef\u8fd0\u884c\u793a\u4f8b&#xff1a;\u5e26\u6e10\u53d8\u4e0e\u6297\u952f\u9f7f\u7684\u81ea\u5b9a\u4e49\u63a7\u4ef6<\/h4>\n<p>\/\/ widget.h<br \/>\n#ifndef WIDGET_H<br \/>\n#define WIDGET_H<br \/>\n#include &lt;QWidget&gt;<br \/>\nclass Widget : public QWidget {<br \/>\n    Q_OBJECT<br \/>\npublic:<br \/>\n    explicit Widget(QWidget *parent &#061; nullptr);<br \/>\nprotected:<br \/>\n    void paintEvent(QPaintEvent *event) override;<br \/>\n};<br \/>\n#endif<\/p>\n<p>\/\/ widget.cpp<br \/>\n#include &#034;widget.h&#034;<br \/>\n#include &lt;QPainter&gt;<br \/>\n#include &lt;QPainterPath&gt;<br \/>\n#include &lt;QLinearGradient&gt;<\/p>\n<p>Widget::Widget(QWidget *parent) : QWidget(parent) {<br \/>\n    setMinimumSize(400, 300);<br \/>\n}<\/p>\n<p>void Widget::paintEvent(QPaintEvent *) {<br \/>\n    QPainter p(this);<br \/>\n    p.setRenderHint(QPainter::Antialiasing, true); \/\/ \u6297\u952f\u9f7f&#xff0c;\u753b\u66f2\u7ebf\u5fc5\u5907<\/p>\n<p>    \/\/ 1) \u6e10\u53d8\u5706\u89d2\u77e9\u5f62<br \/>\n    QLinearGradient grad(0, 0, width(), height());<br \/>\n    grad.setColorAt(0.0, QColor(70, 130, 220));<br \/>\n    grad.setColorAt(1.0, QColor(30, 60, 130));<br \/>\n    p.setBrush(grad);<br \/>\n    p.setPen(QPen(Qt::white, 2));<br \/>\n    p.drawRoundedRect(rect().adjusted(10, 10, -10, -10), 12, 12);<\/p>\n<p>    \/\/ 2) \u8d1d\u585e\u5c14\u66f2\u7ebf\u8def\u5f84<br \/>\n    QPainterPath curve;<br \/>\n    curve.moveTo(20, 200);<br \/>\n    curve.cubicTo(120, 40, 280, 260, 380, 120);<br \/>\n    p.setPen(QPen(QColor(255, 220, 100), 3));<br \/>\n    p.setBrush(Qt::NoBrush);<br \/>\n    p.drawPath(curve);<\/p>\n<p>    \/\/ 3) \u5c45\u4e2d\u6587\u6848<br \/>\n    p.setPen(Qt::white);<br \/>\n    p.setFont(QFont(&#034;Microsoft YaHei&#034;, 14, QFont::Bold));<br \/>\n    p.drawText(rect(), Qt::AlignCenter, &#034;Hello QPainter&#034;);<br \/>\n}<\/p>\n<h4 id=\"32-\u5750\u6807\u53d8\u6362\u5b9e\u6218\u7ed8\u5236\u65cb\u8f6c\u7684\u98ce\u6247\u53f6\u7247\">3.2 \u5750\u6807\u53d8\u6362\u5b9e\u6218&#xff1a;\u7ed8\u5236\u65cb\u8f6c\u7684\u98ce\u6247\u53f6\u7247<\/h4>\n<p>void FanWidget::paintEvent(QPaintEvent *) {<br \/>\n    QPainter p(this);<br \/>\n    p.setRenderHint(QPainter::Antialiasing);<br \/>\n    const QPointF c &#061; rect().center();<br \/>\n    const int n &#061; 3;<br \/>\n    for (int i &#061; 0; i &lt; n; &#043;&#043;i) {<br \/>\n        p.save();                     \/\/ \u4fdd\u5b58\u672a\u53d8\u6362\u72b6\u6001<br \/>\n        p.translate(c);               \/\/ \u5e73\u79fb\u5230\u4e2d\u5fc3<br \/>\n        p.rotate(angle_ &#043; i * 360.0 \/ n); \/\/ \u65cb\u8f6c<br \/>\n        p.setBrush(QColor(80, 160, 255, 180));<br \/>\n        p.setPen(Qt::NoPen);<br \/>\n        p.drawEllipse(QRectF(-90, -20, 180, 40)); \/\/ \u4ee5\u539f\u70b9\u4e3a\u4e2d\u5fc3\u7684\u53f6\u7247<br \/>\n        p.restore();                  \/\/ \u6062\u590d&#xff0c;\u907f\u514d\u65cb\u8f6c\u53e0\u52a0<br \/>\n    }<br \/>\n}<\/p>\n<p>\u8981\u70b9&#xff1a;\u6bcf\u6b21\u53d8\u6362\u524d save\u3001\u7ed3\u675f\u540e restore&#xff0c;\u5426\u5219\u7b2c\u4e8c\u6b21\u5faa\u73af\u7684 rotate \u4f1a\u5728\u7b2c\u4e00\u6b21\u57fa\u7840\u4e0a\u53e0\u52a0&#xff0c;\u53f6\u7247\u4f1a\u8d8a\u8f6c\u8d8a\u6b6a\u3002<\/p>\n<h4 id=\"33-\u79bb\u5c4f\u6e32\u67d3-\u7f13\u5b58\u62d6\u52a8\u4e0d\u95ea\u70c1\u7684\u753b\u677f\">3.3 \u79bb\u5c4f\u6e32\u67d3 &#043; \u7f13\u5b58&#xff1a;\u62d6\u52a8\u4e0d\u95ea\u70c1\u7684\u753b\u677f<\/h4>\n<p>class BoardWidget : public QWidget {<br \/>\n    QPixmap canvas_;<br \/>\n    QPoint last_;<br \/>\nprotected:<br \/>\n    void paintEvent(QPaintEvent *) override {<br \/>\n        QPainter p(this);<br \/>\n        p.drawPixmap(0, 0, canvas_);      \/\/ \u6bcf\u6b21\u91cd\u7ed8\u53ea\u9700 blit \u7f13\u5b58<br \/>\n    }<br \/>\n    void mousePressEvent(QMouseEvent *e) override {<br \/>\n        last_ &#061; e-&gt;pos();<br \/>\n    }<br \/>\n    void mouseMoveEvent(QMouseEvent *e) override {<br \/>\n        QPainter p(&amp;canvas_);              \/\/ \u76f4\u63a5\u5728\u7f13\u5b58\u4e0a\u7ed8\u5236<br \/>\n        p.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));<br \/>\n        p.drawLine(last_, e-&gt;pos());<br \/>\n        last_ &#061; e-&gt;pos();<br \/>\n        update();                          \/\/ \u89e6\u53d1\u91cd\u7ed8&#xff0c;paintEvent \u4e2d blit<br \/>\n    }<br \/>\n    void resizeEvent(QResizeEvent *e) override {<br \/>\n        QPixmap next(size());<br \/>\n        next.fill(Qt::white);<br \/>\n        QPainter p(&amp;next);<br \/>\n        p.drawPixmap(0, 0, canvas_);       \/\/ \u4fdd\u7559\u65e7\u5185\u5bb9<br \/>\n        canvas_ &#061; next;<br \/>\n        QWidget::resizeEvent(e);<br \/>\n    }<br \/>\n};<\/p>\n<p>\u8fd9\u662f\u767d\u677f\/\u6d82\u9e26\u7c7b\u5e94\u7528\u7684\u6807\u51c6\u67b6\u6784&#xff1a;\u4ea4\u4e92\u7ed8\u5236\u5230\u79bb\u5c4f\u7f13\u5b58&#xff0c;paintEvent \u53ea\u505a blit&#xff0c;\u5929\u7136\u9632\u95ea\u70c1\u3001\u6027\u80fd\u9ad8\u3002<\/p>\n<h4 id=\"34-\u7b80\u5355\u67f1\u72b6\u56feqpainter-\u624b\u5199\u56fe\u8868\">3.4 \u7b80\u5355\u67f1\u72b6\u56fe&#xff08;QPainter \u624b\u5199\u56fe\u8868&#xff09;<\/h4>\n<p>void ChartWidget::paintEvent(QPaintEvent *) {<br \/>\n    QPainter p(this);<br \/>\n    p.setRenderHint(QPainter::Antialiasing);<br \/>\n    const QVector&lt;double&gt; data{42, 78, 55, 91, 66};<br \/>\n    const int n &#061; data.size();<br \/>\n    const double bw &#061; width() \/ double(n) * 0.6; \/\/ \u67f1\u5bbd<br \/>\n    const double maxV &#061; 100.0;<\/p>\n<p>    \/\/ \u5750\u6807\u8f74<br \/>\n    p.setPen(QPen(Qt::gray, 1));<br \/>\n    p.drawLine(QPointF(20, height() &#8211; 20), QPointF(width() &#8211; 10, height() &#8211; 20));<br \/>\n    p.drawLine(QPointF(20, height() &#8211; 20), QPointF(20, 10));<\/p>\n<p>    \/\/ \u67f1\u4f53&#xff08;\u9876\u90e8\u6e10\u53d8&#xff09;<br \/>\n    for (int i &#061; 0; i &lt; n; &#043;&#043;i) {<br \/>\n        double h &#061; data[i] \/ maxV * (height() &#8211; 60);<br \/>\n        double x &#061; 30 &#043; i * (width() &#8211; 40) \/ n &#043; (width() &#8211; 40) \/ n * 0.2;<br \/>\n        QRectF bar(x, height() &#8211; 20 &#8211; h, bw, h);<br \/>\n        QLinearGradient g(bar.topLeft(), bar.bottomLeft());<br \/>\n        g.setColorAt(0, QColor(90, 170, 255));<br \/>\n        g.setColorAt(1, QColor(40, 90, 200));<br \/>\n        p.setBrush(g);<br \/>\n        p.setPen(Qt::NoPen);<br \/>\n        p.drawRoundedRect(bar, 3, 3);<br \/>\n        \/\/ \u6570\u503c\u6807\u7b7e<br \/>\n        p.setPen(Qt::black);<br \/>\n        p.drawText(bar.adjusted(0, -22, 0, -6), Qt::AlignCenter, QString::number(data[i]));<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3 id=\"4-\u5e38\u9519\u70b9-\u5751\u9ad8\u53d1\u6e05\u5355\">4. \u5e38\u9519\u70b9 \/ \u5751&#xff08;\u9ad8\u53d1\u6e05\u5355&#xff09;<\/h3>\n<h4 id=\"41-\u91cd\u590d-begin-\u5bfc\u81f4\u8b66\u544a\u6216\u5d29\u6e83\">4.1 \u91cd\u590d begin \u5bfc\u81f4\u8b66\u544a\u6216\u5d29\u6e83<\/h4>\n<p>\u7528\u00a0QPainter p(this)\u00a0\u540e\u53c8\u5728\u51fd\u6570\u91cc\u8c03\u7528\u00a0p.begin(&#8230;)&#xff0c;\u6216\u5bf9\u5df2 begin \u7684 painter \u518d\u6b21 begin&#xff0c;\u4f1a\u8f93\u51fa\u00a0QPainter::begin: Painter already active\u00a0\u4e14\u8fd4\u56de false\u3002\u89c4\u5219&#xff1a;\u6808\u4e0a\u6784\u9020\u5373 begin&#xff0c;\u4e4b\u540e\u53ea\u51c6 end \u4e00\u6b21&#xff08;\u53ef\u7701\u7565&#xff09;&#xff1b;\u9700\u8981\u5207\u6362\u8bbe\u5907\u65f6\u7528\u65e0\u53c2\u6784\u9020 &#043; \u663e\u5f0f begin\u3002<\/p>\n<h4 id=\"42-\u5728-paintevent-\u4e4b\u5916\u7ed8\u5236-qwidget-\u4e0d\u751f\u6548\">4.2 \u5728 paintEvent \u4e4b\u5916\u7ed8\u5236 QWidget \u4e0d\u751f\u6548<\/h4>\n<p>QWidget \u7684\u5185\u5bb9\u7ed8\u5236\u53ea\u80fd\u53d1\u751f\u5728 paintEvent \u4e2d&#xff08;\u7cfb\u7edf\u968f\u65f6\u4f1a\u64e6\u9664\u91cd\u753b&#xff09;\u3002\u60f3\u4e3b\u52a8\u91cd\u753b\u8c03\u7528\u00a0update()&#xff08;\u5408\u5e76\u8bf7\u6c42&#xff09;\u6216\u00a0repaint()&#xff08;\u7acb\u5373\u91cd\u753b&#xff0c;\u963b\u585e&#xff0c;\u614e\u7528&#xff09;\u3002\u975e paintEvent \u4e2d\u753b widget \u7684\u6b63\u786e\u505a\u6cd5&#xff1a;\u753b\u5230\u79bb\u5c4f QPixmap\/QImage&#xff0c;\u518d\u5728 paintEvent \u91cc blit\u3002<\/p>\n<h4 id=\"43-\u53d8\u6362\u672a-saverestore-\u5bfc\u81f4\u6c61\u67d3\">4.3 \u53d8\u6362\u672a save\/restore \u5bfc\u81f4\u6c61\u67d3<\/h4>\n<p>translate\/rotate\/scale \u662f\u6709\u72b6\u6001\u7684&#xff0c;\u4f1a\u5f71\u54cd\u5176\u540e\u7684\u6240\u6709\u7ed8\u5236\u3002\u5fd8\u8bb0 restore \u7684\u5178\u578b\u75c7\u72b6&#xff1a;\u7b2c\u4e8c\u6b21\u5237\u65b0\u753b\u9762\u4f4d\u7f6e\u8d8a\u504f\u8d8a\u8fdc\u3001\u56fe\u5f62\u8d8a\u6765\u8d8a\u5c0f\/\u5927\u3002\u6bcf\u4e2a\u53d8\u6362\u5757\u524d\u540e\u5fc5\u987b save()\/restore() \u914d\u5bf9\u3002<\/p>\n<h4 id=\"44-\u9ad8-dpi-\u7f29\u653e\u6a21\u7cca\">4.4 \u9ad8 DPI \/ \u7f29\u653e\u6a21\u7cca<\/h4>\n<ul>\n<li>\u672a\u542f\u7528\u9ad8 DPI \u652f\u6301\u65f6&#xff0c;\u9ad8\u5206\u5c4f\u4e0a QPainter \u753b\u7684\u6587\u5b57\/\u7ebf\u6761\u53d1\u865a&#xff1a;\u7a0b\u5e8f\u5165\u53e3\u52a0\u00a0QApplication::setHighDpiScaleFactorRoundingPolicy(&#8230;)&#xff0c;\u5e76\u5728 main \u6700\u524d\u9762\u00a0QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling)&#xff08;Qt 5&#xff1b;Qt 6 \u9ed8\u8ba4\u5f00\u542f&#xff09;\u3002<\/li>\n<li>\u56fe\u7247\u62c9\u4f38\u6a21\u7cca&#xff1a;\u9700\u8981\u00a0SmoothPixmapTransform\u00a0\u6e32\u67d3\u63d0\u793a\u3002<\/li>\n<li>\u7ebf\u6761\u968f\u7f29\u653e\u53d8\u7c97&#xff1a;\u60f3\u8981\u6052 1 \u50cf\u7d20\u7528\u5bbd\u5ea6 0&#xff08;cosmetic pen&#xff09;\u3002<\/li>\n<\/ul>\n<h4 id=\"45-\u4e2d\u6587\u4e71\u7801-\u5b57\u4f53\u7f3a\u5931\">4.5 \u4e2d\u6587\u4e71\u7801 \/ \u5b57\u4f53\u7f3a\u5931<\/h4>\n<ul>\n<li>\u660e\u786e\u8bbe\u7f6e\u4e2d\u6587\u5b57\u4f53&#xff1a;QFont(&#034;Microsoft YaHei&#034;)\u00a0\u6216\u00a0&#034;SimHei&#034;&#xff0c;\u4e0d\u8981\u4f9d\u8d56\u9ed8\u8ba4\u5b57\u4f53&#xff1b;<\/li>\n<li>\u7cfb\u7edf\u65e0\u8be5\u5b57\u4f53\u65f6 Qt \u4f1a\u56de\u9000&#xff0c;\u53ef\u80fd\u663e\u793a\u8c46\u8150\u5757&#xff1b;<\/li>\n<li>\u753b\u5e03\u63a7\u4ef6\u8bbe\u7f6e\u5b57\u4f53\u540e\u8bb0\u5f97\u00a0painter.setFont(font)&#xff0c;painter \u4e0d\u4f1a\u81ea\u52a8\u7ee7\u627f widget \u5b57\u4f53\u3002<\/li>\n<\/ul>\n<h4 id=\"46-\u6027\u80fd\u9677\u9631\">4.6 \u6027\u80fd\u9677\u9631<\/h4>\n<ul>\n<li>\u5728 paintEvent \u4e2d\u521b\u5efa\u6e10\u53d8\/\u5b57\u4f53\/\u5927\u5bf9\u8c61&#xff1a;\u6bcf\u6b21\u91cd\u7ed8\u90fd\u91cd\u5efa\u3002\u5e94\u5728\u6784\u9020\u51fd\u6570\u7f13\u5b58\u4e3a\u6210\u5458\u53d8\u91cf\u3002<\/li>\n<li>\u6297\u952f\u9f7f\u5168\u5f00&#xff1a;\u5706\u89d2&#043;\u6e10\u53d8&#043;\u9634\u5f71\u53e0\u52a0\u65f6 CPU \u5f00\u9500\u663e\u8457&#xff0c;\u53ea\u6709\u66f2\u7ebf\/\u659c\u7ebf\u9700\u8981\u65f6\u5f00\u542f&#xff0c;\u77e9\u5f62\/\u6587\u5b57\u53ef\u4e0d\u5f00\u3002<\/li>\n<li>\u9891\u7e41 update() \u9020\u6210\u8fde\u7eed\u91cd\u7ed8&#xff1a;\u5408\u5e76\u4e3a\u5b9a\u65f6\u5668\u8282\u6d41&#xff08;\u5982 30ms \u4e00\u6b21&#xff09;\u3002<\/li>\n<li>\u5927 QPixmap \u53cd\u590d\u7ed8\u5236&#xff1a;\u7528\u00a0drawTiledPixmap\u00a0\u5e73\u94fa\u6216\u7f29\u5c0f\u76ee\u6807\u533a\u57df\u3002<\/li>\n<li>QImage \u9010\u50cf\u7d20 setPixelColor \u5f88\u6162&#xff1a;\u6279\u91cf\u7528\u00a0setPixelColor\u00a0\u5faa\u73af 1000&#215;1000 \u7ea6\u9700\u51e0\u5341 ms \u7ea7&#xff1b;\u9700\u8981\u9ad8\u6027\u80fd\u56fe\u50cf\u5904\u7406\u4f18\u5148\u64cd\u4f5c\u00a0bits()\/scanLine()\u00a0\u6307\u9488\u6216\u6539\u7528 GPU \u65b9\u6848\u3002<\/li>\n<\/ul>\n<h4 id=\"47-qpixmap-\u672a\u586b\u5145\u5c31\u7ed8\u5236\">4.7 QPixmap \u672a\u586b\u5145\u5c31\u7ed8\u5236<\/h4>\n<p>QPixmap pm(size)\u00a0\u521d\u59cb\u5185\u5bb9\u672a\u5b9a\u4e49&#xff08;\u53d6\u51b3\u4e8e\u5e73\u53f0&#xff0c;\u53ef\u80fd\u662f\u5783\u573e\u6570\u636e&#xff09;\u3002\u79bb\u5c4f\u7ed8\u5236\u524d\u5fc5\u987b\u5148\u00a0pm.fill(Qt::transparent)\u00a0\u6216\u586b\u5145\u5e95\u8272&#xff0c;\u5426\u5219\u51fa\u73b0\u82b1\u5c4f\/\u9ed1\u8fb9\u3002<\/p>\n<h4 id=\"48-qimage-\u683c\u5f0f\u9009\u62e9\u9519\u8bef\">4.8 QImage \u683c\u5f0f\u9009\u62e9\u9519\u8bef<\/h4>\n<ul>\n<li>Format_ARGB32\u00a0\u662f\u4e0d\u9884\u4e58 alpha&#xff0c;Format_ARGB32_Premultiplied\u00a0\u662f\u9884\u4e58&#xff0c;\u4e8c\u8005\u6df7\u7528\u4f1a\u5bfc\u81f4\u989c\u8272\u53d1\u6697\/\u53d1\u4eae&#xff1b;<\/li>\n<li>\u9ed8\u8ba4\u00a0Format_ARGB32&#xff08;Qt 5 \u4e2d QImage \u9ed8\u8ba4\u5c31\u662f\u5b83&#xff09;\u5728\u90e8\u5206\u7ed8\u5236\u64cd\u4f5c\u4e0a\u6bd4\u9884\u4e58\u6162&#xff1b;\u9700\u8981 alpha \u5408\u6210\u5efa\u8bae\u7528\u00a0Premultiplied&#xff1b;<\/li>\n<li>Format_RGB32\u00a0\u65e0 alpha&#xff0c;pixelColor\u00a0\u8bfb alpha \u6052\u4e3a 255\u3002<\/li>\n<\/ul>\n<h4 id=\"49-\u7ebf\u7a0b\u7ed8\u5236\u5b89\u5168\">4.9 \u7ebf\u7a0b\u7ed8\u5236\u5b89\u5168<\/h4>\n<p>QPainter \u7ed8\u5236\u00a0QImage\u00a0\u662f\u7ebf\u7a0b\u5b89\u5168\u7684&#xff08;\u53ea\u8981\u8be5 QImage \u4e0d\u88ab\u5176\u5b83\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199&#xff09;&#xff0c;\u4f46\u7ed8\u5236\u00a0QPixmap \/ QWidget\u00a0\u4e0d\u662f\u3002\u540e\u53f0\u7ebf\u7a0b\u753b\u56fe\u8bf7\u7528 QImage&#xff0c;\u5b8c\u6210\u540e\u901a\u8fc7\u4fe1\u53f7\u69fd\u628a\u7ed3\u679c\u4ea4\u7ed9 GUI \u7ebf\u7a0b\u518d\u8f6c QPixmap \u4e0a\u5c4f\u3002<\/p>\n<h4 id=\"410-drawtext-\u5bf9\u4e0d\u9f50-\u6d4b\u91cf\u8bef\u5dee\">4.10 drawText \u5bf9\u4e0d\u9f50 \/ \u6d4b\u91cf\u8bef\u5dee<\/h4>\n<ul>\n<li>drawText(QPoint, &#8230;)\u00a0\u7684 y \u662f\u57fa\u7ebf&#xff08;baseline&#xff09;\u5750\u6807&#xff0c;\u4e0d\u662f\u6587\u5b57\u9876\u90e8&#xff0c;\u7b2c\u4e00\u773c\u89c9\u5f97&#034;\u504f\u4e0a\u4e86&#034;\u662f\u6b63\u5e38\u7684&#xff1b;<\/li>\n<li>\u60f3\u8981\u7cbe\u786e\u5c45\u4e2d\u7528\u00a0drawText(QRect, Qt::AlignCenter, &#8230;)&#xff1b;<\/li>\n<li>\u5bbd\u5ea6\u6d4b\u91cf\u7528\u00a0QFontMetrics::horizontalAdvance&#xff08;\u4e0d\u8981\u7528\u5e9f\u5f03\u7684\u00a0width()&#xff0c;\u591a\u5b57\u8282\u5b57\u7b26\u4f1a\u504f\u5c0f&#xff09;\u3002<\/li>\n<\/ul>\n<h4 id=\"411-\u7ec4\u5408\u6a21\u5f0f\u72b6\u6001\u6cc4\u6f0f\">4.11 \u7ec4\u5408\u6a21\u5f0f\u72b6\u6001\u6cc4\u6f0f<\/h4>\n<p>\u8bbe\u7f6e\u4e86\u00a0CompositionMode_Clear\u00a0\u6216\u00a0Source\u00a0\u540e\u5fd8\u8bb0\u6062\u590d\u00a0SourceOver&#xff0c;\u540e\u7eed\u6240\u6709\u7ed8\u5236\u90fd\u4f1a\u53d8\u6210\u8986\u76d6\/\u64e6\u9664\u6548\u679c\u3002\u6539\u7ec4\u5408\u6a21\u5f0f\u540c\u6837\u5efa\u8bae save\/restore \u5305\u88f9\u3002<\/p>\n<h4 id=\"412-resizeevent-\u4e2d\u672a\u4fdd\u7559\u753b\u677f\u5185\u5bb9\">4.12 resizeEvent \u4e2d\u672a\u4fdd\u7559\u753b\u677f\u5185\u5bb9<\/h4>\n<p>\u753b\u677f\u7c7b\u63a7\u4ef6 resize \u540e QPixmap \u5c3a\u5bf8\u53d8\u5316&#xff0c;\u76f4\u63a5 new \u4e00\u5757\u7a7a\u7684\u4f1a\u628a\u65e7\u5185\u5bb9\u6e05\u6389&#xff1b;\u5e94\u6309 3.3 \u793a\u4f8b\u628a\u65e7\u753b\u5e03\u5185\u5bb9\u590d\u5236\u5230\u65b0\u753b\u5e03\u3002<\/p>\n<hr \/>\n<h3 id=\"5-\u603b\u7ed3\">5. \u603b\u7ed3<\/h3>\n<p>QPainter \u662f Qt 2D \u7ed8\u5236\u7684\u6839&#xff1a;\u81ea\u5b9a\u4e49\u63a7\u4ef6\u3001\u79bb\u5c4f\u6e32\u67d3\u3001\u56fe\u8868\u3001\u753b\u677f\u3001\u751a\u81f3\u4e0a\u5c42 Graphics View \/ QCustomPlot \/ QML \u573a\u666f\u56fe&#xff0c;\u5e95\u5c42\u90fd\u79bb\u4e0d\u5f00\u5b83\u3002\u638c\u63e1\u5b83\u7684\u5173\u952e\u662f\u7406\u89e3\u4e09\u4ef6\u4e8b&#xff1a;<\/p>\n<li>\u72b6\u6001\u673a\u6a21\u578b&#xff1a;pen\/brush\/font\/transform\/renderHint \u90fd\u662f&#034;\u5f53\u524d\u72b6\u6001&#034;&#xff0c;\u7ed8\u5236\u51fd\u6570\u5373\u65f6\u6d88\u8d39\u5f53\u524d\u72b6\u6001\u2014\u2014\u6240\u4ee5 save\/restore \u662f\u63a7\u5236\u72b6\u6001\u6c61\u67d3\u7684\u552f\u4e00\u53ef\u9760\u624b\u6bb5&#xff1b;<\/li>\n<li>\u8bbe\u5907\u65e0\u5173&#xff1a;QPainter \u53ef\u4ee5\u753b\u5230 QWidget\/QPixmap\/QImage\/QPicture \u4efb\u610f\u8bbe\u5907&#xff0c;\u8fd9\u4e00\u62bd\u8c61\u8ba9&#034;\u79bb\u5c4f\u7f13\u5b58 &#043; \u4e0a\u5c4f blit&#034;\u6210\u4e3a\u6027\u80fd\u4f18\u5316\u7684\u4e07\u80fd\u94a5\u5319&#xff1b;<\/li>\n<li>\u5750\u6807\u53d8\u6362&#xff1a;translate\/rotate\/scale \u662f\u7ed8\u5236\u590d\u6742\u56fe\u5f62&#xff08;\u4eea\u8868\u3001\u6247\u5f62\u3001\u65cb\u8f6c\u5143\u7d20&#xff09;\u7684\u6839\u57fa&#xff0c;\u914d\u5408 QPainterPath \u53ef\u4ee5\u8868\u8fbe\u4efb\u610f\u77e2\u91cf\u5f62\u72b6\u3002<\/li>\n<p>\u65e5\u5e38\u4f7f\u7528\u8bb0\u4f4f 8 \u6761\u907f\u5751\u94c1\u5f8b&#xff1a;begin \u53ea\u4e00\u6b21\u3001\u7ed8\u5236\u53ea\u5728 paintEvent\u3001\u53d8\u6362\u5fc5\u914d\u5bf9 save\/restore\u3001QPixmap \u5148 fill\u3001\u6297\u952f\u9f7f\u6309\u9700\u5f00\u3001\u4e2d\u6587\u663e\u5f0f\u8bbe\u5b57\u4f53\u3001QImage \u9884\u4e58\u683c\u5f0f\u3001\u7ebf\u7a0b\u753b QImage \u4e0d\u753b QPixmap\u3002<\/p>\n<h4 id=\"faq-\u901f\u67e5\u8868\">FAQ \u901f\u67e5\u8868<\/h4>\n<table>\n<tbody>\n<tr>\u95ee\u9898\u4e00\u53e5\u8bdd\u7b54\u6848<\/tr>\n<tr>\n<td>\u753b\u7b14\u5bbd\u5ea6\u4e3a 0 \u662f\u4ec0\u4e48\u610f\u601d&#xff1f;<\/td>\n<td>cosmetic \u7b14&#xff0c;\u6052\u4e3a 1 \u50cf\u7d20&#xff0c;\u4e0d\u968f scale \u53d8\u7c97<\/td>\n<\/tr>\n<tr>\n<td>\u60f3\u753b\u900f\u660e\u80cc\u666f\u7684\u7f13\u5b58\u56fe&#xff1f;<\/td>\n<td>pm.fill(Qt::transparent)\u00a0\u4e14\u4f7f\u7528\u5e26 alpha \u7684\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td>\u753b\u51fa\u6765\u7684\u5706\u6709\u952f\u9f7f&#xff1f;<\/td>\n<td>setRenderHint(QPainter::Antialiasing, true)<\/td>\n<\/tr>\n<tr>\n<td>\u91cd\u7ed8\u95ea\u70c1\u600e\u4e48\u529e&#xff1f;<\/td>\n<td>\u79bb\u5c4f QPixmap \u7ed8\u5236 &#043; paintEvent \u53ea blit<\/td>\n<\/tr>\n<tr>\n<td>\u5982\u4f55\u6e05\u7a7a\u753b\u677f&#xff1f;<\/td>\n<td>canvas.fill(Qt::white)\u00a0\u540e\u00a0update()<\/td>\n<\/tr>\n<tr>\n<td>\u540e\u53f0\u7ebf\u7a0b\u80fd\u7ed8\u5236\u5417&#xff1f;<\/td>\n<td>\u53ea\u80fd\u753b QImage&#xff0c;\u753b\u5b8c\u8f6c QPixmap \u4ea4 GUI \u7ebf\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u5b57\u5782\u76f4\u4e0d\u5bf9\u9f50&#xff1f;<\/td>\n<td>drawText(QPoint) \u7684 y \u662f\u57fa\u7ebf&#xff1b;\u5c45\u4e2d\u7528 QRect \u91cd\u8f7d<\/td>\n<\/tr>\n<tr>\n<td>\u56fe\u7247\u653e\u5927\u6a21\u7cca&#xff1f;<\/td>\n<td>SmoothPixmapTransform\u00a0\u6e32\u67d3\u63d0\u793a<\/td>\n<\/tr>\n<tr>\n<td>\u9ad8 DPI \u4e0b\u6a21\u7cca&#xff1f;<\/td>\n<td>Qt6 \u9ed8\u8ba4\u5f00\u542f&#xff1b;Qt5 \u9700 AA_EnableHighDpiScaling<\/td>\n<\/tr>\n<tr>\n<td>\u5982\u4f55\u4fdd\u5b58\u7ed8\u5236\u7ed3\u679c&#xff1f;<\/td>\n<td>QImage::save(path)&#xff1b;\u77e2\u91cf\u4fdd\u5b58\u7528 QPicture \u6216\u5bfc\u51fa SVG&#xff08;QSvgGenerator&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>1. \u80cc\u666fQt \u7684 2D \u6e32\u67d3\u4f53\u7cfb\u81ea\u5e95\u5411\u4e0a\u5927\u81f4\u5206\u4e3a\u4e09\u5c42&#xff1a;\u5c42\u7ea7\u7ec4\u4ef6\u5b9a\u4f4d\u5e95\u5c42\u6e32\u67d3\u540e\u7aefQPainter  QPaintDevice\u76f4\u63a5\u7ed8\u5236 2D \u56fe\u5143&#xff08;\u7ebf\u3001\u77e9\u5f62\u3001\u692d\u5706\u3001\u8def\u5f84\u3001\u6587\u5b57\u3001\u56fe\u50cf&#xff09;\u5230\u4efb\u610f\u53ef\u7ed8\u8868\u9762\u4e2d\u95f4\u573a\u666f\u5c42QGraphicsView \/ QGraphicsScene \/ QGraphicsItem\u5728 QPainter \u4e4b\u4e0a\u5c01\u88c5\u573a\u666f-\u89c6\u56fe-\u56fe\u5143\u67b6\u6784&#xff0c;\u63d0\u4f9b\u5bf9\u8c61\u5316\u7ba1\u7406\u4e0a\u5c42\u58f0\u660e\u5f0f UIQML \/ Qt Quick&#xff08;S<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11653,55,218],"topic":[],"class_list":["post-107082","post","type-post","status-publish","format-standard","hentry","category-server","tag-11653","tag-c","tag-qt"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/107082.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. \u80cc\u666fQt \u7684 2D \u6e32\u67d3\u4f53\u7cfb\u81ea\u5e95\u5411\u4e0a\u5927\u81f4\u5206\u4e3a\u4e09\u5c42&#xff1a;\u5c42\u7ea7\u7ec4\u4ef6\u5b9a\u4f4d\u5e95\u5c42\u6e32\u67d3\u540e\u7aefQPainter QPaintDevice\u76f4\u63a5\u7ed8\u5236 2D \u56fe\u5143&#xff08;\u7ebf\u3001\u77e9\u5f62\u3001\u692d\u5706\u3001\u8def\u5f84\u3001\u6587\u5b57\u3001\u56fe\u50cf&#xff09;\u5230\u4efb\u610f\u53ef\u7ed8\u8868\u9762\u4e2d\u95f4\u573a\u666f\u5c42QGraphicsView \/ QGraphicsScene \/ QGraphicsItem\u5728 QPainter \u4e4b\u4e0a\u5c01\u88c5\u573a\u666f-\u89c6\u56fe-\u56fe\u5143\u67b6\u6784&#xff0c;\u63d0\u4f9b\u5bf9\u8c61\u5316\u7ba1\u7406\u4e0a\u5c42\u58f0\u660e\u5f0f UIQML \/ Qt Quick&#xff08;S\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/107082.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-18T15:08:33+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/107082.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/107082.html\",\"name\":\"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-18T15:08:33+00:00\",\"dateModified\":\"2026-09-18T15:08:33+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/107082.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/107082.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/107082.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/107082.html","og_locale":"zh_CN","og_type":"article","og_title":"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. \u80cc\u666fQt \u7684 2D \u6e32\u67d3\u4f53\u7cfb\u81ea\u5e95\u5411\u4e0a\u5927\u81f4\u5206\u4e3a\u4e09\u5c42&#xff1a;\u5c42\u7ea7\u7ec4\u4ef6\u5b9a\u4f4d\u5e95\u5c42\u6e32\u67d3\u540e\u7aefQPainter QPaintDevice\u76f4\u63a5\u7ed8\u5236 2D \u56fe\u5143&#xff08;\u7ebf\u3001\u77e9\u5f62\u3001\u692d\u5706\u3001\u8def\u5f84\u3001\u6587\u5b57\u3001\u56fe\u50cf&#xff09;\u5230\u4efb\u610f\u53ef\u7ed8\u8868\u9762\u4e2d\u95f4\u573a\u666f\u5c42QGraphicsView \/ QGraphicsScene \/ QGraphicsItem\u5728 QPainter \u4e4b\u4e0a\u5c01\u88c5\u573a\u666f-\u89c6\u56fe-\u56fe\u5143\u67b6\u6784&#xff0c;\u63d0\u4f9b\u5bf9\u8c61\u5316\u7ba1\u7406\u4e0a\u5c42\u58f0\u660e\u5f0f UIQML \/ Qt Quick&#xff08;S","og_url":"https:\/\/www.wsisp.com\/helps\/107082.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-18T15:08:33+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/107082.html","url":"https:\/\/www.wsisp.com\/helps\/107082.html","name":"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-18T15:08:33+00:00","dateModified":"2026-09-18T15:08:33+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/107082.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/107082.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/107082.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Qt QPainter 2D \u7ed8\u56fe\u7cfb\u7edf\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u753b\u7b14\u5230\u6e32\u67d3\u5f15\u64ce\u9002"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/107082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=107082"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/107082\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=107082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=107082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=107082"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=107082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}