Qt QPushbutton Icon above Text
The Qt QPushbutton Icon text:
Click this link . QToolButton
QToolButton* button = new QToolButton(this); button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); button->setIcon(myIcon); button->setText("Sample text");
By creating the button widget and copied from QPushButton or QAbstractButton and to focus by the efforts of complementging paintEvent().
The given below code is simple:
QPushButton { padding: -25px 0 10px 0; border: 1px solid black; border-radius: 2px; background-position: center bottom; background-repeat: no-repeat; background-origin: content; background-image: url(":/new/resource/accept.png"); } QPushButton:disabled { background-image: url(":/new/resource/accept_b.png"); }
The simple statement is:
Here the QPushButton is not available. In QPushButton, the options are fixed the LayoutDirection are LeftToRight, RightToLeft and Auto. And to can the QToolButton .
By using the Qt Creator, switch to Design pane, add a QToolButton and in the right side bottom pane, an option ‘textFormat’, in that select ToolButtonTextUnderIcon.
Modify: The textFormat are changed to toolButtonStyle in the versions of Qt Creator (4.7.0).