Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_gui_painting_qcolor.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QPainter>
4
6int width() { return 1; };
7int height() { return 1; };
9void wrapper() {
10
11
13// Specify semi-transparent red
14painter.setBrush(QColor(255, 0, 0, 127));
15painter.drawRect(0, 0, width() / 2, height());
16
17// Specify semi-transparent blue
18painter.setBrush(QColor(0, 0, 255, 127));
19painter.drawRect(0, 0, width(), height() / 2);
21
23const QRgb rgb1 = 0x88112233;
24const QRgb rgb2 = QColor("red").rgb();
25const QRgb rgb3 = qRgb(qRed(rgb1), qGreen(rgb2), qBlue(rgb2));
26const QRgb rgb4 = qRgba(qRed(rgb1), qGreen(rgb2), qBlue(rgb2), qAlpha(rgb1));
28Q_UNUSED(rgb3);
29Q_UNUSED(rgb4);
30
31} // wrapper
32} // src_gui_painting_qcolor
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
QRgb rgb() const noexcept
Returns the RGB value of the color.
Definition qcolor.cpp:1439
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition qpainter.h:519
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13
constexpr QRgb qRgb(int r, int g, int b)
Definition qrgb.h:30
constexpr int qRed(QRgb rgb)
Definition qrgb.h:18
constexpr int qGreen(QRgb rgb)
Definition qrgb.h:21
constexpr QRgb qRgba(int r, int g, int b, int a)
Definition qrgb.h:33
constexpr int qBlue(QRgb rgb)
Definition qrgb.h:24
constexpr int qAlpha(QRgb rgb)
Definition qrgb.h:27
#define Q_UNUSED(x)