Qt QPushbutton Icon above Text

前端 未结 3 470
借酒劲吻你
借酒劲吻你 2021-01-03 19:16

When I create a QPushButton with an Icon it by default displays the text to the right of the icon. Is there a way to have the text display underneath the icon?

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 20:01

    This is not possible with QPushButton. In QPushButton, the only placement options (LayoutDirection) are LeftToRight, RightToLeft and Auto. But you can use QToolButton instead.

    Use Qt Creator, switch to Design pane, add a QToolButton and in the right side bottom pane, you will see an option 'textFormat', in that select ToolButtonTextUnderIcon.

    Update: The textFormat option has been changed to toolButtonStyle in recent versions of Qt Creator (4.7.0).

提交回复
热议问题