<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qbrush.cpp --> <title>QBrush Class | Qt GUI 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QBrush</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#related-non-members">Related Non-Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QBrush Class</h1> <!-- $$$QBrush-brief --> <p>The <a href="qbrush.html">QBrush</a> class defines the fill pattern of shapes drawn by <a href="qpainter.html">QPainter</a>. <a href="#details">More...</a></p> <!-- @@@QBrush --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QBrush></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><ul> <li><a href="qbrush-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush">QBrush</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-1">QBrush</a></b>(Qt::BrushStyle <i>style</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-2">QBrush</a></b>(const QColor &<i>color</i>, Qt::BrushStyle <i>style</i> = Qt::SolidPattern)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-3">QBrush</a></b>(Qt::GlobalColor <i>color</i>, Qt::BrushStyle <i>style</i> = Qt::SolidPattern)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-4">QBrush</a></b>(const QColor &<i>color</i>, const QPixmap &<i>pixmap</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-5">QBrush</a></b>(Qt::GlobalColor <i>color</i>, const QPixmap &<i>pixmap</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-6">QBrush</a></b>(const QPixmap &<i>pixmap</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-7">QBrush</a></b>(const QImage &<i>image</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-8">QBrush</a></b>(const QBrush &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#QBrush-9">QBrush</a></b>(const QGradient &<i>gradient</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#dtor.QBrush">~QBrush</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QColor &</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#color">color</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QGradient *</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#gradient">gradient</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#isOpaque">isOpaque</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QMatrix &</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#matrix">matrix</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setColor">setColor</a></b>(const QColor &<i>color</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setColor-1">setColor</a></b>(Qt::GlobalColor <i>color</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setMatrix">setMatrix</a></b>(const QMatrix &<i>matrix</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setStyle">setStyle</a></b>(Qt::BrushStyle <i>style</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setTexture">setTexture</a></b>(const QPixmap &<i>pixmap</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setTextureImage">setTextureImage</a></b>(const QImage &<i>image</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#setTransform">setTransform</a></b>(const QTransform &<i>matrix</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::BrushStyle </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#style">style</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#swap">swap</a></b>(QBrush &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#texture">texture</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QImage </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#textureImage">textureImage</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QTransform </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#transform">transform</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-QVariant">operator QVariant</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-not-eq">operator!=</a></b>(const QBrush &<i>brush</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QBrush &</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-eq">operator=</a></b>(const QBrush &<i>brush</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QBrush &</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-eq-1">operator=</a></b>(QBrush &&<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-eq-eq">operator==</a></b>(const QBrush &<i>brush</i>) const</td></tr> </table></div> <a name="related-non-members"></a> <h2 id="related-non-members">Related Non-Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-lt-lt">operator<<</a></b>(QDataStream &<i>stream</i>, const QBrush &<i>brush</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qbrush.html#operator-gt-gt">operator>></a></b>(QDataStream &<i>stream</i>, QBrush &<i>brush</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QBrush-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qbrush.html">QBrush</a> class defines the fill pattern of shapes drawn by <a href="qpainter.html">QPainter</a>.</p> <p>A brush has a style, a color, a gradient and a texture.</p> <p>The brush <a href="qbrush.html#style">style</a>() defines the fill pattern using the <a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a> enum. The default brush style is <a href="../qtcore/qt.html#BrushStyle-enum">Qt::NoBrush</a> (depending on how you construct a brush). This style tells the painter to not fill shapes. The standard style for filling is <a href="../qtcore/qt.html#BrushStyle-enum">Qt::SolidPattern</a>. The style can be set when the brush is created using the appropriate constructor, and in addition the <a href="qbrush.html#setStyle">setStyle</a>() function provides means for altering the style once the brush is constructed.</p> <p class="centerAlign"><img src="images/brush-styles.png" alt="Brush Styles" /></p><p>The brush <a href="qbrush.html#color">color</a>() defines the color of the fill pattern. The color can either be one of Qt's predefined colors, <a href="../qtcore/qt.html#GlobalColor-enum">Qt::GlobalColor</a>, or any other custom <a href="qcolor.html">QColor</a>. The currently set color can be retrieved and altered using the <a href="qbrush.html#color">color</a>() and <a href="qbrush.html#setColor">setColor</a>() functions, respectively.</p> <p>The <a href="qbrush.html#gradient">gradient</a>() defines the gradient fill used when the current style is either <a href="../qtcore/qt.html#BrushStyle-enum">Qt::LinearGradientPattern</a>, <a href="../qtcore/qt.html#BrushStyle-enum">Qt::RadialGradientPattern</a> or <a href="../qtcore/qt.html#BrushStyle-enum">Qt::ConicalGradientPattern</a>. Gradient brushes are created by giving a <a href="qgradient.html">QGradient</a> as a constructor argument when creating the <a href="qbrush.html">QBrush</a>. Qt provides three different gradients: <a href="qlineargradient.html">QLinearGradient</a>, <a href="qconicalgradient.html">QConicalGradient</a>, and <a href="qradialgradient.html">QRadialGradient</a> - all of which inherit <a href="qgradient.html">QGradient</a>.</p> <pre class="cpp"> <span class="type"><a href="qradialgradient.html">QRadialGradient</a></span> gradient(<span class="number">50</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">50</span>); gradient<span class="operator">.</span>setColorAt(<span class="number">0</span><span class="operator">,</span> <span class="type"><a href="qcolor.html">QColor</a></span><span class="operator">::</span>fromRgbF(<span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span>)); gradient<span class="operator">.</span>setColorAt(<span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qcolor.html">QColor</a></span><span class="operator">::</span>fromRgbF(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>)); <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> brush(gradient); </pre> <p>The <a href="qbrush.html#texture">texture</a>() defines the pixmap used when the current style is <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>. You can create a brush with a texture by providing the pixmap when the brush is created or by using <a href="qbrush.html#setTexture">setTexture</a>().</p> <p>Note that applying <a href="qbrush.html#setTexture">setTexture</a>() makes <a href="qbrush.html#style">style</a>() == <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>, regardless of previous style settings. Also, calling <a href="qbrush.html#setColor">setColor</a>() will not make a difference if the style is a gradient. The same is the case if the style is <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a> style unless the current texture is a <a href="qbitmap.html">QBitmap</a>.</p> <p>The <a href="qbrush.html#isOpaque">isOpaque</a>() function returns <code>true</code> if the brush is fully opaque otherwise false. A brush is considered opaque if:</p> <ul> <li>The alpha component of the <a href="qbrush.html#color">color</a>() is 255.</li> <li>Its <a href="qbrush.html#texture">texture</a>() does not have an alpha channel and is not a <a href="qbitmap.html">QBitmap</a>.</li> <li>The colors in the <a href="qbrush.html#gradient">gradient</a>() all have an alpha component that is 255.</li> </ul> <div class="table"><table class="generic" width="100%"> <tr valign="top" class="odd"><td ><img src="images/brush-outline.png" alt="Outlines" /></td><td >To specify the style and color of lines and outlines, use the <a href="qpainter.html">QPainter</a>'s <a href="qpen.html">pen</a> combined with <a href="../qtcore/qt.html#PenStyle-enum">Qt::PenStyle</a> and <a href="../qtcore/qt.html#GlobalColor-enum">Qt::GlobalColor</a>:<pre class="cpp"> <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(<span class="type">Qt</span><span class="operator">::</span>cyan); painter<span class="operator">.</span>setPen(<span class="type">Qt</span><span class="operator">::</span>darkCyan); painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span><span class="number">100</span>); painter<span class="operator">.</span>setBrush(<span class="type">Qt</span><span class="operator">::</span>NoBrush); painter<span class="operator">.</span>setPen(<span class="type">Qt</span><span class="operator">::</span>darkGreen); painter<span class="operator">.</span>drawRect(<span class="number">40</span><span class="operator">,</span> <span class="number">40</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>); </pre> <p>Note that, by default, <a href="qpainter.html">QPainter</a> renders the outline (using the currently set pen) when drawing shapes. Use <a href="../qtcore/qt.html#PenStyle-enum"><code>painter.setPen(Qt::NoPen)</code></a> to disable this behavior.</p> </td></tr> </table></div> <p>For more information about painting in general, see the <a href="paintsystem.html">Paint System</a>.</p> </div> <p><b>See also </b><a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a>, <a href="qpainter.html">QPainter</a>, and <a href="qcolor.html">QColor</a>.</p> <!-- @@@QBrush --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QBrush[overload1]$$$QBrush --> <h3 class="fn" id="QBrush"><a name="QBrush"></a>QBrush::<span class="name">QBrush</span>()</h3> <p>Constructs a default black brush with the style <a href="../qtcore/qt.html#BrushStyle-enum">Qt::NoBrush</a> (i.e. this brush will not fill shapes).</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushQt::BrushStyle --> <h3 class="fn" id="QBrush-1"><a name="QBrush-1"></a>QBrush::<span class="name">QBrush</span>(<span class="type"><a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a></span> <i>style</i>)</h3> <p>Constructs a black brush with the given <i>style</i>.</p> <p><b>See also </b><a href="qbrush.html#setStyle">setStyle</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushconstQColor&Qt::BrushStyle --> <h3 class="fn" id="QBrush-2"><a name="QBrush-2"></a>QBrush::<span class="name">QBrush</span>(const <span class="type"><a href="qcolor.html">QColor</a></span> &<i>color</i>, <span class="type"><a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a></span> <i>style</i> = Qt::SolidPattern)</h3> <p>Constructs a brush with the given <i>color</i> and <i>style</i>.</p> <p><b>See also </b><a href="qbrush.html#setColor">setColor</a>() and <a href="qbrush.html#setStyle">setStyle</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushQt::GlobalColorQt::BrushStyle --> <h3 class="fn" id="QBrush-3"><a name="QBrush-3"></a>QBrush::<span class="name">QBrush</span>(<span class="type"><a href="../qtcore/qt.html#GlobalColor-enum">Qt::GlobalColor</a></span> <i>color</i>, <span class="type"><a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a></span> <i>style</i> = Qt::SolidPattern)</h3> <p>Constructs a brush with the given <i>color</i> and <i>style</i>.</p> <p><b>See also </b><a href="qbrush.html#setColor">setColor</a>() and <a href="qbrush.html#setStyle">setStyle</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushconstQColor&constQPixmap& --> <h3 class="fn" id="QBrush-4"><a name="QBrush-4"></a>QBrush::<span class="name">QBrush</span>(const <span class="type"><a href="qcolor.html">QColor</a></span> &<i>color</i>, const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &<i>pixmap</i>)</h3> <p>Constructs a brush with the given <i>color</i> and the custom pattern stored in <i>pixmap</i>.</p> <p>The style is set to <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>. The color will only have an effect for QBitmaps.</p> <p><b>See also </b><a href="qbrush.html#setColor">setColor</a>() and <a href="qbrush.html#setTexture">setTexture</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushQt::GlobalColorconstQPixmap& --> <h3 class="fn" id="QBrush-5"><a name="QBrush-5"></a>QBrush::<span class="name">QBrush</span>(<span class="type"><a href="../qtcore/qt.html#GlobalColor-enum">Qt::GlobalColor</a></span> <i>color</i>, const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &<i>pixmap</i>)</h3> <p>Constructs a brush with the given <i>color</i> and the custom pattern stored in <i>pixmap</i>.</p> <p>The style is set to <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>. The color will only have an effect for QBitmaps.</p> <p><b>See also </b><a href="qbrush.html#setColor">setColor</a>() and <a href="qbrush.html#setTexture">setTexture</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushconstQPixmap& --> <h3 class="fn" id="QBrush-6"><a name="QBrush-6"></a>QBrush::<span class="name">QBrush</span>(const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &<i>pixmap</i>)</h3> <p>Constructs a brush with a black color and a texture set to the given <i>pixmap</i>. The style is set to <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>.</p> <p><b>See also </b><a href="qbrush.html#setTexture">setTexture</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushconstQImage& --> <h3 class="fn" id="QBrush-7"><a name="QBrush-7"></a>QBrush::<span class="name">QBrush</span>(const <span class="type"><a href="qimage.html">QImage</a></span> &<i>image</i>)</h3> <p>Constructs a brush with a black color and a texture set to the given <i>image</i>. The style is set to <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>.</p> <p><b>See also </b><a href="qbrush.html#setTextureImage">setTextureImage</a>().</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushconstQBrush& --> <h3 class="fn" id="QBrush-8"><a name="QBrush-8"></a>QBrush::<span class="name">QBrush</span>(const <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>other</i>)</h3> <p>Constructs a copy of <i>other</i>.</p> <!-- @@@QBrush --> <!-- $$$QBrush$$$QBrushconstQGradient& --> <h3 class="fn" id="QBrush-9"><a name="QBrush-9"></a>QBrush::<span class="name">QBrush</span>(const <span class="type"><a href="qgradient.html">QGradient</a></span> &<i>gradient</i>)</h3> <p>Constructs a brush based on the given <i>gradient</i>.</p> <p>The brush style is set to the corresponding gradient style (either <a href="../qtcore/qt.html#BrushStyle-enum">Qt::LinearGradientPattern</a>, <a href="../qtcore/qt.html#BrushStyle-enum">Qt::RadialGradientPattern</a> or <a href="../qtcore/qt.html#BrushStyle-enum">Qt::ConicalGradientPattern</a>).</p> <!-- @@@QBrush --> <!-- $$$~QBrush[overload1]$$$~QBrush --> <h3 class="fn" id="dtor.QBrush"><a name="dtor.QBrush"></a>QBrush::<span class="name">~QBrush</span>()</h3> <p>Destroys the brush.</p> <!-- @@@~QBrush --> <!-- $$$color[overload1]$$$color --> <h3 class="fn" id="color"><a name="color"></a>const <span class="type"><a href="qcolor.html">QColor</a></span> &QBrush::<span class="name">color</span>() const</h3> <p>Returns the brush color.</p> <p><b>See also </b><a href="qbrush.html#setColor">setColor</a>().</p> <!-- @@@color --> <!-- $$$gradient[overload1]$$$gradient --> <h3 class="fn" id="gradient"><a name="gradient"></a>const <span class="type"><a href="qgradient.html">QGradient</a></span> *QBrush::<span class="name">gradient</span>() const</h3> <p>Returns the gradient describing this brush.</p> <!-- @@@gradient --> <!-- $$$isOpaque[overload1]$$$isOpaque --> <h3 class="fn" id="isOpaque"><a name="isOpaque"></a><span class="type">bool</span> QBrush::<span class="name">isOpaque</span>() const</h3> <p>Returns <code>true</code> if the brush is fully opaque otherwise false. A brush is considered opaque if:</p> <ul> <li>The alpha component of the <a href="qbrush.html#color">color</a>() is 255.</li> <li>Its <a href="qbrush.html#texture">texture</a>() does not have an alpha channel and is not a <a href="qbitmap.html">QBitmap</a>.</li> <li>The colors in the <a href="qbrush.html#gradient">gradient</a>() all have an alpha component that is 255.</li> <li>It is an extended radial gradient.</li> </ul> <!-- @@@isOpaque --> <!-- $$$matrix[overload1]$$$matrix --> <h3 class="fn" id="matrix"><a name="matrix"></a>const <span class="type"><a href="qmatrix.html">QMatrix</a></span> &QBrush::<span class="name">matrix</span>() const</h3> <p>Returns the current transformation matrix for the brush.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also </b><a href="qbrush.html#setMatrix">setMatrix</a>().</p> <!-- @@@matrix --> <!-- $$$setColor[overload1]$$$setColorconstQColor& --> <h3 class="fn" id="setColor"><a name="setColor"></a><span class="type">void</span> QBrush::<span class="name">setColor</span>(const <span class="type"><a href="qcolor.html">QColor</a></span> &<i>color</i>)</h3> <p>Sets the brush color to the given <i>color</i>.</p> <p>Note that calling setColor() will not make a difference if the style is a gradient. The same is the case if the style is <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a> style unless the current texture is a <a href="qbitmap.html">QBitmap</a>.</p> <p><b>See also </b><a href="qbrush.html#color">color</a>().</p> <!-- @@@setColor --> <!-- $$$setColor$$$setColorQt::GlobalColor --> <h3 class="fn" id="setColor-1"><a name="setColor-1"></a><span class="type">void</span> QBrush::<span class="name">setColor</span>(<span class="type"><a href="../qtcore/qt.html#GlobalColor-enum">Qt::GlobalColor</a></span> <i>color</i>)</h3> <p>This is an overloaded function.</p> <p>Sets the brush color to the given <i>color</i>.</p> <!-- @@@setColor --> <!-- $$$setMatrix[overload1]$$$setMatrixconstQMatrix& --> <h3 class="fn" id="setMatrix"><a name="setMatrix"></a><span class="type">void</span> QBrush::<span class="name">setMatrix</span>(const <span class="type"><a href="qmatrix.html">QMatrix</a></span> &<i>matrix</i>)</h3> <p>Sets <i>matrix</i> as an explicit transformation matrix on the current brush. The brush transformation matrix is merged with <a href="qpainter.html">QPainter</a> transformation matrix to produce the final result.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also </b><a href="qbrush.html#matrix">matrix</a>().</p> <!-- @@@setMatrix --> <!-- $$$setStyle[overload1]$$$setStyleQt::BrushStyle --> <h3 class="fn" id="setStyle"><a name="setStyle"></a><span class="type">void</span> QBrush::<span class="name">setStyle</span>(<span class="type"><a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a></span> <i>style</i>)</h3> <p>Sets the brush style to <i>style</i>.</p> <p><b>See also </b><a href="qbrush.html#style">style</a>().</p> <!-- @@@setStyle --> <!-- $$$setTexture[overload1]$$$setTextureconstQPixmap& --> <h3 class="fn" id="setTexture"><a name="setTexture"></a><span class="type">void</span> QBrush::<span class="name">setTexture</span>(const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &<i>pixmap</i>)</h3> <p>Sets the brush pixmap to <i>pixmap</i>. The style is set to <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>.</p> <p>The current brush color will only have an effect for monochrome pixmaps, i.e. for <a href="qpixmap.html#depth">QPixmap::depth</a>() == 1 (<a href="qbitmap.html">QBitmaps</a>).</p> <p><b>See also </b><a href="qbrush.html#texture">texture</a>().</p> <!-- @@@setTexture --> <!-- $$$setTextureImage[overload1]$$$setTextureImageconstQImage& --> <h3 class="fn" id="setTextureImage"><a name="setTextureImage"></a><span class="type">void</span> QBrush::<span class="name">setTextureImage</span>(const <span class="type"><a href="qimage.html">QImage</a></span> &<i>image</i>)</h3> <p>Sets the brush image to <i>image</i>. The style is set to <a href="../qtcore/qt.html#BrushStyle-enum">Qt::TexturePattern</a>.</p> <p>Note the current brush color will <i>not</i> have any affect on monochrome images, as opposed to calling <a href="qbrush.html#setTexture">setTexture</a>() with a <a href="qbitmap.html">QBitmap</a>. If you want to change the color of monochrome image brushes, either convert the image to <a href="qbitmap.html">QBitmap</a> with <code>QBitmap::fromImage()</code> and set the resulting <a href="qbitmap.html">QBitmap</a> as a texture, or change the entries in the color table for the image.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also </b><a href="qbrush.html#textureImage">textureImage</a>() and <a href="qbrush.html#setTexture">setTexture</a>().</p> <!-- @@@setTextureImage --> <!-- $$$setTransform[overload1]$$$setTransformconstQTransform& --> <h3 class="fn" id="setTransform"><a name="setTransform"></a><span class="type">void</span> QBrush::<span class="name">setTransform</span>(const <span class="type"><a href="qtransform.html">QTransform</a></span> &<i>matrix</i>)</h3> <p>Sets <i>matrix</i> as an explicit transformation matrix on the current brush. The brush transformation matrix is merged with <a href="qpainter.html">QPainter</a> transformation matrix to produce the final result.</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also </b><a href="qbrush.html#transform">transform</a>().</p> <!-- @@@setTransform --> <!-- $$$style[overload1]$$$style --> <h3 class="fn" id="style"><a name="style"></a><span class="type"><a href="../qtcore/qt.html#BrushStyle-enum">Qt::BrushStyle</a></span> QBrush::<span class="name">style</span>() const</h3> <p>Returns the brush style.</p> <p><b>See also </b><a href="qbrush.html#setStyle">setStyle</a>().</p> <!-- @@@style --> <!-- $$$swap[overload1]$$$swapQBrush& --> <h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QBrush::<span class="name">swap</span>(<span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>other</i>)</h3> <p>Swaps brush <i>other</i> with this brush. This operation is very fast and never fails.</p> <p>This function was introduced in Qt 4.8.</p> <!-- @@@swap --> <!-- $$$texture[overload1]$$$texture --> <h3 class="fn" id="texture"><a name="texture"></a><span class="type"><a href="qpixmap.html">QPixmap</a></span> QBrush::<span class="name">texture</span>() const</h3> <p>Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set.</p> <p><b>See also </b><a href="qbrush.html#setTexture">setTexture</a>().</p> <!-- @@@texture --> <!-- $$$textureImage[overload1]$$$textureImage --> <h3 class="fn" id="textureImage"><a name="textureImage"></a><span class="type"><a href="qimage.html">QImage</a></span> QBrush::<span class="name">textureImage</span>() const</h3> <p>Returns the custom brush pattern, or a null image if no custom brush pattern has been set.</p> <p>If the texture was set as a <a href="qpixmap.html">QPixmap</a> it will be converted to a <a href="qimage.html">QImage</a>.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also </b><a href="qbrush.html#setTextureImage">setTextureImage</a>().</p> <!-- @@@textureImage --> <!-- $$$transform[overload1]$$$transform --> <h3 class="fn" id="transform"><a name="transform"></a><span class="type"><a href="qtransform.html">QTransform</a></span> QBrush::<span class="name">transform</span>() const</h3> <p>Returns the current transformation matrix for the brush.</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also </b><a href="qbrush.html#setTransform">setTransform</a>().</p> <!-- @@@transform --> <!-- $$$operator QVariant[overload1]$$$operator QVariant --> <h3 class="fn" id="operator-QVariant"><a name="operator-QVariant"></a><span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> QBrush::<span class="name">operator QVariant</span>() const</h3> <p>Returns the brush as a <a href="../qtcore/qvariant.html">QVariant</a></p> <!-- @@@operator QVariant --> <!-- $$$operator!=[overload1]$$$operator!=constQBrush& --> <h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QBrush::<span class="name">operator!=</span>(const <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>brush</i>) const</h3> <p>Returns <code>true</code> if the brush is different from the given <i>brush</i>; otherwise returns <code>false</code>.</p> <p>Two brushes are different if they have different styles, colors or transforms or different pixmaps or gradients depending on the style.</p> <p><b>See also </b><a href="qbrush.html#operator-eq-eq">operator==</a>().</p> <!-- @@@operator!= --> <!-- $$$operator=[overload1]$$$operator=constQBrush& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &QBrush::<span class="name">operator=</span>(const <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>brush</i>)</h3> <p>Assigns the given <i>brush</i> to <i>this</i> brush and returns a reference to <i>this</i> brush.</p> <!-- @@@operator= --> <!-- $$$operator=$$$operator=QBrush&& --> <h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &QBrush::<span class="name">operator=</span>(<span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &&<i>other</i>)</h3> <p>Move-assigns <i>other</i> to this <a href="qbrush.html">QBrush</a> instance.</p> <p>This function was introduced in Qt 5.2.</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQBrush& --> <h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QBrush::<span class="name">operator==</span>(const <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>brush</i>) const</h3> <p>Returns <code>true</code> if the brush is equal to the given <i>brush</i>; otherwise returns <code>false</code>.</p> <p>Two brushes are equal if they have equal styles, colors and transforms and equal pixmaps or gradients depending on the style.</p> <p><b>See also </b><a href="qbrush.html#operator-not-eq">operator!=</a>().</p> <!-- @@@operator== --> </div> <div class="relnonmem"> <h2>Related Non-Members</h2> <!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQBrush& --> <h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<span class="name">operator<<</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<i>stream</i>, const <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>brush</i>)</h3> <p>Writes the given <i>brush</i> to the given <i>stream</i> and returns a reference to the <i>stream</i>.</p> <p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p> <!-- @@@operator<< --> <!-- $$$operator>>[overload1]$$$operator>>QDataStream&QBrush& --> <h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<span class="name">operator>></span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &<i>stream</i>, <span class="type"><a href="qbrush.html#QBrush">QBrush</a></span> &<i>brush</i>)</h3> <p>Reads the given <i>brush</i> from the given <i>stream</i> and returns a reference to the <i>stream</i>.</p> <p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p> <!-- @@@operator>> --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>