blob: 66eb7b9c1878257c33d363d971a363f70e65ff97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QIcon>
#include <QPainter>
#include <QToolButton>
#include <QSize>
namespace src_gui_image_qicon {
struct MyWidget : public QWidget
{
void drawIcon(QPainter *painter, const QRect &rect);
bool isChecked() { return true; }
QIcon icon;
};
void wrapper0() {
//! [0]
QToolButton *button = new QToolButton;
button->setIcon(QIcon("open.png"));
//! [0]
QSize size(1, 1);
//! [addFile]
QIcon openIcon("open.png");
openIcon.addFile("open-disabled.png", size ,QIcon::Disabled);
//! [addFile]
//! [1]
button->setIcon(QIcon());
//! [1]
} // wrapper0
//! [2]
void MyWidget::drawIcon(QPainter *painter, const QRect &rect)
{
icon.paint(painter, rect, Qt::AlignCenter, isEnabled() ? QIcon::Normal
: QIcon::Disabled,
isChecked() ? QIcon::On
: QIcon::Off);
}
//! [2]
using namespace Qt::StringLiterals;
void wrapper1() {
//! [fromTheme]
QIcon undoicon = QIcon::fromTheme(QIcon::ThemeIcon::EditUndo);
//! [fromTheme]
//! [iconFont]
QIcon::setThemeName("Material Symbols Outlined");
QIcon muteIcon = QIcon::fromTheme(u"volume_off"_s);
//! [iconFont]
} // wrapper1
//! [4]
QIcon undoicon = QIcon::fromTheme(QIcon::ThemeIcon::EditUndo, QIcon(":/undo.png"));
//! [4]
void wrapper2(){
//! [5]
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << "my/search/path");
//! [5]
} // wrapper2
} // src_gui_image_qicon
|