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
qicon.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QICON_H
5#define QICON_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qsize.h>
9#include <QtCore/qlist.h>
10#include <QtGui/qpixmap.h>
11
13
14
15class QIconPrivate;
16class QIconEngine;
17class QPainter;
18
19class Q_GUI_EXPORT QIcon
20{
21public:
22 enum Mode { Normal, Disabled, Active, Selected };
23 enum State { On, Off };
24
25 enum class ThemeIcon {
26 AddressBookNew,
27 ApplicationExit,
28 AppointmentNew,
29 CallStart,
30 CallStop,
31 ContactNew,
32 DocumentNew,
33 DocumentOpen,
34 DocumentOpenRecent,
35 DocumentPageSetup,
36 DocumentPrint,
37 DocumentPrintPreview,
38 DocumentProperties,
39 DocumentRevert,
40 DocumentSave,
41 DocumentSaveAs,
42 DocumentSend,
43 EditClear,
44 EditCopy,
45 EditCut,
46 EditDelete,
47 EditFind,
48 EditPaste,
49 EditRedo,
50 EditSelectAll,
51 EditUndo,
52 FolderNew,
53 FormatIndentLess,
54 FormatIndentMore,
55 FormatJustifyCenter,
56 FormatJustifyFill,
57 FormatJustifyLeft,
58 FormatJustifyRight,
59 FormatTextDirectionLtr,
60 FormatTextDirectionRtl,
61 FormatTextBold,
62 FormatTextItalic,
63 FormatTextUnderline,
64 FormatTextStrikethrough,
65 GoDown,
66 GoHome,
67 GoNext,
68 GoPrevious,
69 GoUp,
70 HelpAbout,
71 HelpFaq,
72 InsertImage,
73 InsertLink,
75 ListAdd,
76 ListRemove,
77 MailForward,
78 MailMarkImportant,
79 MailMarkRead,
80 MailMarkUnread,
81 MailMessageNew,
82 MailReplyAll,
83 MailReplySender,
84 MailSend,
85 MediaEject,
86 MediaPlaybackPause,
87 MediaPlaybackStart,
88 MediaPlaybackStop,
89 MediaRecord,
90 MediaSeekBackward,
91 MediaSeekForward,
92 MediaSkipBackward,
93 MediaSkipForward,
94 ObjectRotateLeft,
95 ObjectRotateRight,
96 ProcessStop,
97 SystemLockScreen,
98 SystemLogOut,
99 SystemSearch,
100 SystemReboot,
101 SystemShutdown,
102 ToolsCheckSpelling,
103 ViewFullscreen,
104 ViewRefresh,
105 ViewRestore,
106 WindowClose,
107 WindowNew,
108 ZoomFitBest,
109 ZoomIn,
110 ZoomOut,
111
112 AudioCard,
113 AudioInputMicrophone,
114 Battery,
115 CameraPhoto,
116 CameraVideo,
117 CameraWeb,
118 Computer,
119 DriveHarddisk,
120 DriveOptical,
121 InputGaming,
122 InputKeyboard,
123 InputMouse,
124 InputTablet,
125 MediaFlash,
126 MediaOptical,
127 MediaTape,
128 MultimediaPlayer,
129 NetworkWired,
130 NetworkWireless,
131 Phone,
132 Printer,
133 Scanner,
134 VideoDisplay,
135
136 AppointmentMissed,
137 AppointmentSoon,
138 AudioVolumeHigh,
139 AudioVolumeLow,
140 AudioVolumeMedium,
141 AudioVolumeMuted,
142 BatteryCaution,
143 BatteryLow,
144 DialogError,
145 DialogInformation,
146 DialogPassword,
147 DialogQuestion,
148 DialogWarning,
149 FolderDragAccept,
150 FolderOpen,
151 FolderVisiting,
152 ImageLoading,
153 ImageMissing,
154 MailAttachment,
155 MailUnread,
156 MailRead,
157 MailReplied,
158 MediaPlaylistRepeat,
159 MediaPlaylistShuffle,
160 NetworkOffline,
161 PrinterPrinting,
162 SecurityHigh,
163 SecurityLow,
164 SoftwareUpdateAvailable,
165 SoftwareUpdateUrgent,
166 SyncError,
167 SyncSynchronizing,
168 UserAvailable,
169 UserOffline,
170 WeatherClear,
171 WeatherClearNight,
172 WeatherFewClouds,
173 WeatherFewCloudsNight,
174 WeatherFog,
175 WeatherShowers,
176 WeatherSnow,
177 WeatherStorm,
178
179 NThemeIcons
180 };
181
182 QIcon() noexcept;
183 QIcon(const QPixmap &pixmap);
184 QIcon(const QIcon &other);
185 QIcon(QIcon &&other) noexcept
186 : d(std::exchange(other.d, nullptr))
187 {}
188 explicit QIcon(const QString &fileName); // file or resource name
189 explicit QIcon(QIconEngine *engine);
190 ~QIcon();
191 QIcon &operator=(const QIcon &other);
192 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QIcon)
193 inline void swap(QIcon &other) noexcept
194 { qt_ptr_swap(d, other.d); }
195 bool operator==(const QIcon &) const = delete;
196 bool operator!=(const QIcon &) const = delete;
197
198 operator QVariant() const;
199
200 QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
201 inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const
202 { return pixmap(QSize(w, h), mode, state); }
203 inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const
204 { return pixmap(QSize(extent, extent), mode, state); }
205 QPixmap pixmap(const QSize &size, qreal devicePixelRatio, Mode mode = Normal, State state = Off) const;
206#if QT_DEPRECATED_SINCE(6, 0)
207 QT_DEPRECATED_VERSION_X_6_0("Use pixmap(size, devicePixelRatio) instead")
209#endif
210
211 QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
212#if QT_DEPRECATED_SINCE(6, 0)
213 QT_DEPRECATED_VERSION_X_6_0("Use actualSize(size) instead")
214 QSize actualSize(QWindow *window, const QSize &size, Mode mode = Normal, State state = Off) const;
215#endif
216
217 QString name() const;
218
219 void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
220 inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const
221 { paint(painter, QRect(x, y, w, h), alignment, mode, state); }
222
223 bool isNull() const;
224 bool isDetached() const;
225 void detach();
226
227 qint64 cacheKey() const;
228
229 void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off);
230 void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off);
231
232 QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const;
233
234 void setIsMask(bool isMask);
235 bool isMask() const;
236
237 static QIcon fromTheme(const QString &name);
238 static QIcon fromTheme(const QString &name, const QIcon &fallback);
239 static bool hasThemeIcon(const QString &name);
240
241 static QIcon fromTheme(ThemeIcon icon);
242 static QIcon fromTheme(ThemeIcon icon, const QIcon &fallback);
243 static bool hasThemeIcon(ThemeIcon icon);
244
245 static QStringList themeSearchPaths();
246 static void setThemeSearchPaths(const QStringList &searchpath);
247
248 static QStringList fallbackSearchPaths();
249 static void setFallbackSearchPaths(const QStringList &paths);
250
251 static QString themeName();
252 static void setThemeName(const QString &path);
253
254 static QString fallbackThemeName();
255 static void setFallbackThemeName(const QString &name);
256
257private:
259#if !defined(QT_NO_DATASTREAM)
260 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
261 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
262#endif
263
264public:
266 inline DataPtr &data_ptr() { return d; }
267};
268
269Q_DECLARE_SHARED(QIcon)
270
271#if !defined(QT_NO_DATASTREAM)
272Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
273Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
274#endif
275
276#ifndef QT_NO_DEBUG_STREAM
277Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QIcon &);
278#endif
279
280Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,
281 qreal *sourceDevicePixelRatio = nullptr);
282
284
285#endif // QICON_H
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
The QIconEngine class provides an abstract base class for QIcon renderers.
Definition qiconengine.h:15
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
QPixmap pixmap(int w, int h, Mode mode=Normal, State state=Off) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qicon.h:201
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
@ Active
Definition qicon.h:22
QIconPrivate * DataPtr
Definition qicon.h:265
bool operator!=(const QIcon &) const =delete
QPixmap pixmap(int extent, Mode mode=Normal, State state=Off) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qicon.h:203
DataPtr & data_ptr()
Definition qicon.h:266
bool operator==(const QIcon &) const =delete
ThemeIcon
Definition qicon.h:25
void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qicon.h:220
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
\inmodule QtGui
Definition qwindow.h:63
QPainter paint
rect
[4]
uint alignment
else opt state
[0]
Combined button and popup list for selecting options.
@ AlignCenter
Definition qnamespace.h:163
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QIcon &)
Definition qicon.cpp:1849
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QIcon &)
Definition qicon.cpp:1888
Q_GUI_EXPORT QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, qreal *sourceDevicePixelRatio=nullptr)
Definition qicon.cpp:1984
static QByteArray cacheKey(Args &&...args)
static QString themeName()
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLuint * paths
GLuint name
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLsizei const GLchar *const * path
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
#define QT_DEPRECATED_VERSION_X_6_0(text)
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QSharedPointer< T > other(t)
[5]
this swap(other)
widget render & pixmap
QPainter painter(this)
[7]
aWidget window() -> setWindowTitle("New Window Title")
[2]
new InsertText(document, idx, text, insertRed)
QJSEngine engine
[0]