QPixmap pixmap("image.png"); QIcon icon(pixmap);
QPushButton button; QPixmap pixmap("image.png"); QIcon icon(pixmap); button.setIcon(icon);In this example, a QPushButton object is created and the QIcon object is set as its icon using the setIcon method. Package library: Qt framework.