Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QToolButton different text display policy between single and multi-line



  • Hello,

    I have two QToolButton displaying an icon, and under this icon a text with one or two lines. I can see that when the text has a single line, it displays from the left border to the right border, and it is constrained with no margin (default padding is 0, so this is normal).
    But in multiline (\n separating two words), the text is constrained as if big left and right margins were present.

    I use QT 5.12, PyQT to be precise.

    Screenshots :
    Screenshot from 2020-03-04 10-30-52.png
    You can see "Result Database" left and right margin are bigger then "Start Batch"

    Screenshot from 2020-03-04 10-31-19.png
    But when donwsizing a bit the width, "Result Database" text is unexpectedly altered whereas "Start Batch" displays still ok (and I can even resize until it touches the borders)

    ToolButtonStyle is set to "ToolButtonUnderIcon", there is no stylesheet declared for any of the QToolButton, and if I add "padding-left: 0px; padding-right: 0px;" it does not change anything. Icon is 32 by 32, buttons are 70 (min) to 100 (max) width, and 72 height.

    Is this normal ? Do you know any reason to explain this behavior ?

    Could I disable the automatic text modification behavior (apparition of "..."), I would prefer clipping ?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Looks like related to QTBUG-64132.


  • Qt Champions 2019

    What exact Qt5.12 version do you use? This should be fixed in at least the recent one.



  • Thank you very much @Christian-Ehrlicher and @SGaist for your quick and pertinent answers , I read related bugs description and saw that in 5.12.4 bug had probably been fixed. I was using 5.12.0.

    I had the possibility to upgrade a little my runtime version for Qt, and installed directly 5.13.0, and tested : it works fine. I mark the subject as closed !


Log in to reply