Home

Published

- 1 min read

PySide: QPushbutton Text below Icon

img of PySide: QPushbutton Text below Icon

Apparently using a QPushbutton with an Icon does not work. As alternative, I am going to use a QToolbutton.

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class Widget(QWidget):

    def __init__(self, parent= None):
        super(Widget, self).__init__()

        layout = QVBoxLayout(self)

        #QToolButton
        btn = QToolButton()
        btn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        btn.setText("test")
        btn.setIcon(btn.style().standardIcon(QStyle.SP_DirIcon))
        btn.setIconSize(QSize(54,54))

        layout.addWidget(btn)

        self.setLayout(layout)

if __name__ == '__main__':
    app = QApplication(sys.argv)

    dialog = Widget()
    dialog.show()

    app.exec_()