Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt5 how to add icon on text or above text in pushbutton
Qt 6.11 is out! See what's new in the release blog

PyQt5 how to add icon on text or above text in pushbutton

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abdullah.S
    wrote on last edited by
    #1

    Hi, is that possible to add icon on text or above text in pushbutton ?
    I could not find any information about this question in forums and documentations

    JonBJ 1 Reply Last reply
    0
    • A Abdullah.S

      Hi, is that possible to add icon on text or above text in pushbutton ?
      I could not find any information about this question in forums and documentations

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Abdullah-S
      First, what is the issue with QPushButton::setIcon()? If that does not do what you want then explain what is lacking and we can review from there.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Abdullah.S
        wrote on last edited by
        #3

        @JonB said in PyQt5 how to add icon on text or above text in pushbutton:

        QPushButton::setIcon()

        thank you for answer but my problem is not with adding icon, I can add icon on pushbutton but I cannot move it on the text or above the text.

        JonBJ 1 Reply Last reply
        0
        • A Abdullah.S

          @JonB said in PyQt5 how to add icon on text or above text in pushbutton:

          QPushButton::setIcon()

          thank you for answer but my problem is not with adding icon, I can add icon on pushbutton but I cannot move it on the text or above the text.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Abdullah-S
          I believe that is indeed the case. QPushButton layout is limited. If you cannot get what you want in CSS or code --- which does not surprise me for QPushButton --- then you must "roll your own" "pressable button" instead, e.g. from a QLabel or a QWidget, or maybe from a QAbstractButton or derive from QPushButton and override its paintEvent().

          A 1 Reply Last reply
          2
          • JonBJ JonB

            @Abdullah-S
            I believe that is indeed the case. QPushButton layout is limited. If you cannot get what you want in CSS or code --- which does not surprise me for QPushButton --- then you must "roll your own" "pressable button" instead, e.g. from a QLabel or a QWidget, or maybe from a QAbstractButton or derive from QPushButton and override its paintEvent().

            A Offline
            A Offline
            Abdullah.S
            wrote on last edited by
            #5

            @JonB thank you I will try it

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved