diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-28 12:58:31 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-10-12 13:00:43 +0200 |
commit | 80958297587c278ae44938d21f59c37cd8b77f0c (patch) | |
tree | 2eb50b10e7a8af1c15ff5b998a2ec506d26286c8 /src/gui | |
parent | 0aa8925f1acd47cadc71483cac97d202444d15db (diff) |
Improve QRgb documentation
- Add examples of how to create QRgb values
- Link to qRgba()
Pick-to: 5.15 5.12
Change-Id: I2a86b1c8e00137ba868426b8157a3aa0d924d7a6
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp b/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp index fa3d7c9733..ecb52d0756 100644 --- a/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp +++ b/src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp @@ -66,6 +66,14 @@ painter.setBrush(QColor(0, 0, 255, 127)); painter.drawRect(0, 0, width(), height() / 2); //! [0] +//! [QRgb] +const QRgb rgb1 = 0x88112233; +const QRgb rgb2 = QColor("red").rgb(); +const QRgb rgb3 = qRgb(qRed(rgb1), qGreen(rgb2), qBlue(rgb2)); +const QRgb rgb4 = qRgba(qRed(rgb1), qGreen(rgb2), qBlue(rgb2), qAlpha(rgb1)); +//! [QRgb] +Q_UNUSED(rgb3); +Q_UNUSED(rgb4); } // wrapper } // src_gui_painting_qcolor diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 46f212fa7a..f6f77518b5 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -3203,7 +3203,11 @@ const uint qt_inv_premul_factor[256] = { channel is \c ff, i.e opaque. For more information, see the \l{QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing} section. - \sa QColor::rgb(), QColor::rgba() + Here are some exammples of how QRgb values can be created: + + \snippet code/src_gui_painting_qcolor.cpp QRgb + + \sa qRgb(), qRgba(), QColor::rgb(), QColor::rgba() */ /*! |