Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_image_qicon.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 <QIcon>
4#include <QPainter>
5#include <QToolButton>
6#include <QSize>
7
9
10struct MyWidget : public QWidget
11{
12 void drawIcon(QPainter *painter, const QRect &rect);
13 bool isChecked() { return true; }
15};
16
17void wrapper0() {
18
19//! [0]
20QToolButton *button = new QToolButton;
21button->setIcon(QIcon("open.png"));
22//! [0]
23
24QSize size(1, 1);
25
26//! [addFile]
27QIcon openIcon("open.png");
28openIcon.addFile("open-disabled.png", size ,QIcon::Disabled);
29//! [addFile]
30
31//! [1]
32button->setIcon(QIcon());
33//! [1]
34
35} // wrapper0
36
37
38//! [2]
39void MyWidget::drawIcon(QPainter *painter, const QRect &rect)
40{
41 icon.paint(painter, rect, Qt::AlignCenter, isEnabled() ? QIcon::Normal
42 : QIcon::Disabled,
43 isChecked() ? QIcon::On
44 : QIcon::Off);
45}
46//! [2]
47
48using namespace Qt::StringLiterals;
49
50void wrapper1() {
51
52//! [fromTheme]
53QIcon undoicon = QIcon::fromTheme(QIcon::ThemeIcon::EditUndo);
54//! [fromTheme]
55
56//! [iconFont]
57QIcon::setThemeName("Material Symbols Outlined");
58QIcon muteIcon = QIcon::fromTheme(u"volume_off"_s);
59//! [iconFont]
60
61} // wrapper1
62
63
64//! [4]
66//! [4]
67
68
69void wrapper2(){
70//! [5]
71QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << "my/search/path");
72//! [5]
73
74} // wrapper2
75} // src_gui_image_qicon
void drawIcon(QPainter *painter, const QRect &rect)
[2]