blob: a7f27a7fdd2b48ba38e0373f7e3413d96e4aef2b (
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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QIcon>
#include <QPainter>
#include <QToolButton>
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]
//! [addFile]
QIcon openIcon("open.png");
openIcon.addFile("open-disabled.png", 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]
void wrapper1() {
//! [fromTheme]
QIcon undoicon = QIcon::fromTheme(QIcon::ThemeIcon::EditUndo);
//! [fromTheme]
} // 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
|