Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QToolButton Icon position
Qt 6.12 LTS is out! See what's new in the release blog

QToolButton Icon position

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 4.4k Views 3 Watching
  • 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.
  • P Offline
    P Offline
    pixbyte
    wrote on last edited by
    #1

    Is it possible to manipulate the position of the Icon inside a QToolButton?
    In my case, the icon is to near the top border, I want to set a top margin to the icon.
    But the setStyleSheet only set the margin to the button itself.

    button->setStyleSheet("QToolButton { margin-top: 10px; } ");
    

    Thanks,

    Ingo

    Pl45m4P A 2 Replies Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt ?
      On what OS ?
      Can you show what you get ?
      Can you show what you would like to achieve ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P pixbyte

        Is it possible to manipulate the position of the Icon inside a QToolButton?
        In my case, the icon is to near the top border, I want to set a top margin to the icon.
        But the setStyleSheet only set the margin to the button itself.

        button->setStyleSheet("QToolButton { margin-top: 10px; } ");
        

        Thanks,

        Ingo

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @pixbyte

        AFAIK you cant use Stylesheet on QIcons directly to set a margin, because a QIcon is not a QWidget.

        Write a custom Button and define a custom icon position / area inside your Button?!


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • P pixbyte

          Is it possible to manipulate the position of the Icon inside a QToolButton?
          In my case, the icon is to near the top border, I want to set a top margin to the icon.
          But the setStyleSheet only set the margin to the button itself.

          button->setStyleSheet("QToolButton { margin-top: 10px; } ");
          

          Thanks,

          Ingo

          A Offline
          A Offline
          arsinte_andrei
          wrote on last edited by
          #4

          @pixbyte
          you should use even stylesheet for all this

          button->setStyleSheet("QToolButton {
          background-image: url(:/path/to/image.jpg);
          margin-top: 10px;
          } ");
          
          

          you can play with background-image or with image
          Not tested but should work

          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
          • Unsolved