summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/src_gui_image_qicon.cpp
blob: 2b7c893150f924071cc26ba8fc43f36fe99219fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! [0]
QToolButton *button = new QToolButton;
button->setIcon(QIcon("open.xpm"));
//! [0]


//! [1]
button->setIcon(QIcon());
//! [1]


//! [2]
void MyWidget::drawIcon(QPainter *painter, QPoint pos)
{
    QPixmap pixmap = icon.pixmap(QSize(22, 22),
                                   isEnabled() ? QIcon::Normal
                                               : QIcon::Disabled,
                                   isOn() ? QIcon::On
                                          : QIcon::Off);
    painter->drawPixmap(pos, pixmap);
}
//! [2]