diff options
| author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-12-06 16:53:53 +0100 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-12-07 12:39:06 +0100 |
| commit | dcfd68c827cc9dbfb746680df77be30fc0afcc4a (patch) | |
| tree | c5a1cb10c4aca12703b9c4172a23b4ddc03f5e89 /src/gui/doc/snippets | |
| parent | 7be14ea88b7b60979447c6e27050d922c1ed790b (diff) | |
QIcon: Clean up documentation
Structure the overview documentation a bit more around the different
ways to create a QIcon (from resources or theme). Replace the use of
QIcon::pixmap with a call to QIcon::paint in the example widget, and
tighten the High-DPI documentation a bit.
This does not add any mentioning of the upcoming "native icon library"
support.
Change-Id: I9cc7eab1fb5d134e5119660b534c2efdb0b03730
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/doc/snippets')
| -rw-r--r-- | src/gui/doc/snippets/code/src_gui_image_qicon.cpp | 20 |
1 files changed, 11 insertions, 9 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 d446f16c3cd..f7875b7c7cf 100644 --- a/src/gui/doc/snippets/code/src_gui_image_qicon.cpp +++ b/src/gui/doc/snippets/code/src_gui_image_qicon.cpp @@ -8,7 +8,7 @@ namespace src_gui_image_qicon { struct MyWidget : public QWidget { - void drawIcon(QPainter *painter, QPoint pos); + void drawIcon(QPainter *painter, const QRect &rect); bool isChecked() { return true; } QIcon icon; }; @@ -17,9 +17,13 @@ void wrapper0() { //! [0] QToolButton *button = new QToolButton; -button->setIcon(QIcon("open.xpm")); +button->setIcon(QIcon("open.png")); //! [0] +//! [addFile] +QIcon openIcon("open.png"); +openIcon.addFile("open-disabled.png", QIcon::Disabled); +//! [addFile] //! [1] button->setIcon(QIcon()); @@ -29,14 +33,12 @@ button->setIcon(QIcon()); //! [2] -void MyWidget::drawIcon(QPainter *painter, QPoint pos) +void MyWidget::drawIcon(QPainter *painter, const QRect &rect) { - QPixmap pixmap = icon.pixmap(QSize(22, 22), - isEnabled() ? QIcon::Normal - : QIcon::Disabled, - isChecked() ? QIcon::On - : QIcon::Off); - painter->drawPixmap(pos, pixmap); + icon.paint(painter, rect, Qt::AlignCenter, isEnabled() ? QIcon::Normal + : QIcon::Disabled, + isChecked() ? QIcon::On + : QIcon::Off); } //! [2] |
