summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets
diff options
context:
space:
mode:
authorVolker Hilsheimer <[email protected]>2024-12-02 17:03:09 +0100
committerVolker Hilsheimer <[email protected]>2024-12-03 10:11:37 +0100
commitf401142d321cfa9de5e1632f7f66a6b5c02525c1 (patch)
treed1ed9dbd6b02e19c36f79e563ce35208c138164c /src/gui/doc/snippets
parentf6d67ed9b760e87af3e032ea49e5babc6951ef91 (diff)
QIcon: document the support for icon fonts
Add a C++ snippet that shows how to use a named glyph from an icon font, and add a QML snippet file that shows how to change the icon based on the state of a tool button. [ChangeLog][Gui][QIcon] QIcon can now generate icons from the named glyphs of an icon font. Change-Id: I1179ed93774c2c209094fffb910b2e06cbe2f572 Reviewed-by: Mitch Curtis <[email protected]>
Diffstat (limited to 'src/gui/doc/snippets')
-rw-r--r--src/gui/doc/snippets/code/src_gui_image_qicon.cpp5
-rw-r--r--src/gui/doc/snippets/code/src_gui_image_qicon.qml16
2 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/doc/snippets/code/src_gui_image_qicon.cpp b/src/gui/doc/snippets/code/src_gui_image_qicon.cpp
index a7f27a7fdd2..2901ddd592b 100644
--- a/src/gui/doc/snippets/code/src_gui_image_qicon.cpp
+++ b/src/gui/doc/snippets/code/src_gui_image_qicon.cpp
@@ -49,6 +49,11 @@ void wrapper1() {
QIcon undoicon = QIcon::fromTheme(QIcon::ThemeIcon::EditUndo);
//! [fromTheme]
+//! [iconFont]
+QIcon::setThemeName("Material Symbols Outlined");
+QIcon muteIcon = QIcon::fromTheme(u"volume_off"_s);
+//! [iconFont]
+
} // wrapper1
diff --git a/src/gui/doc/snippets/code/src_gui_image_qicon.qml b/src/gui/doc/snippets/code/src_gui_image_qicon.qml
new file mode 100644
index 00000000000..e5a653f38bd
--- /dev/null
+++ b/src/gui/doc/snippets/code/src_gui_image_qicon.qml
@@ -0,0 +1,16 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick.Controls
+
+Window {
+
+//! [iconFont]
+ToolButton {
+ id: muteButton
+ checkable: true
+ icon.name: checked ? "volume_off" : "volume_up"
+}
+//! [iconFont]
+
+}