From 80958297587c278ae44938d21f59c37cd8b77f0c Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 28 Sep 2020 12:58:31 +0200 Subject: [PATCH] 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 --- src/gui/doc/snippets/code/src_gui_painting_qcolor.cpp | 8 ++++++++ src/gui/painting/qcolor.cpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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() */ /*!