Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QToolButton: weird padding behavior compared to QPushButton
Forum Updated to NodeBB v4.3 + New Features

QToolButton: weird padding behavior compared to QPushButton

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 3.2k Views 2 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.
  • J Offline
    J Offline
    Justin Sayne
    wrote on last edited by
    #1

    Can someone explain why QToolButton's padding mechanics are so different and counter-intuitive to QPushButton's?

    Here's a QToolButton and QPushButton without any padding:

    alt text

    Now I add left padding of 50px to both buttons. QPushButton behaves as expected, QToolButton sets its padding on the right side - wtf

    alt text

    Ok, lets try it with top-padding, maybe this direction isn't that messed up. 20px top padding:

    alt text

    WTF??
    Why is that?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show a minimal sample code that reproduces this ?

      What OS and Qt Version are you using ?

      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
      • J Offline
        J Offline
        Justin Sayne
        wrote on last edited by
        #3

        I didn't write any code. I made this in QtDesigner, set the padding with style sheets and opened the widget preview.

        OS is Windows 10, Qt Version is 5.3.1 but I can also reproduce it under Qt 5.5

        mrjjM 1 Reply Last reply
        0
        • J Justin Sayne

          I didn't write any code. I made this in QtDesigner, set the padding with style sheets and opened the widget preview.

          OS is Windows 10, Qt Version is 5.3.1 but I can also reproduce it under Qt 5.5

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Justin-Sayne
          Hi
          I dont think QToolButton support padding as its not listed in the list of widgets that does.

          http://doc.qt.io/qt-5/stylesheet-reference.html

          1 Reply Last reply
          4
          • J Offline
            J Offline
            Justin Sayne
            wrote on last edited by
            #5

            Well, if on the same site you seach for QToolButton in the list of styleable widgets, it says it supports the box model. And you can even reach an example from there where they added right padding to a QToolButton.
            It would also be really counter-intuitive if a QToolButton didn't support padding at all but QPushButton does.

            mrjjM 1 Reply Last reply
            0
            • J Justin Sayne

              Well, if on the same site you seach for QToolButton in the list of styleable widgets, it says it supports the box model. And you can even reach an example from there where they added right padding to a QToolButton.
              It would also be really counter-intuitive if a QToolButton didn't support padding at all but QPushButton does.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Justin-Sayne
              I agree it seems odd as ToolButton is also AbstractButton.
              Testet with Qt5.7 and it really seems to ignore padding.
              { margin: 22px } Does work.
              So it seems it support box-model but not the padding part ;)

              So I would have a look in
              https://bugreports.qt.io/browse/QTBUG-14745?jql=text ~ "qtoolbutton"

              too see if reported as bug.

              1 Reply Last reply
              1
              • S Offline
                S Offline
                sola
                wrote on last edited by
                #7

                Well, I face the same problem. Maybe I should subclass the QToolButton.

                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