[Python] How can I place the icon after the text of a QPushButton in PyQt5

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    How can I place the icon after the text of a QPushButton in PyQt5?

    The icon should not come before the text - it should come after or below the text.

    Currently it's looking like this:

    [​IMG]

    but it should be like this: Track ⨁

    from PyQt5.QtWidgets import QApplication, QPushButton, QWidget, QVBoxLayout
    from PyQt5.QtGui import QIcon
    from PyQt5.QtCore import Qt
    import sys

    app = QApplication(sys.argv)

    window = QWidget()
    layout = QVBoxLayout(window)

    btn_add_track = QPushButton("Track")
    btn_add_track.setIcon(QIcon("Icons/plus.png"))
    layout.addWidget(btn_add_track)
    window.show()

    sys.exit(app.exec_())

    Continue reading...

Compartilhe esta Página