To transfer words to a regular QPushButton, you can implement a proxy class class derived from QProxyStyle.
class QtPushButtonStyleProxy : public QProxyStyle { public: QtPushButtonStyleProxy() : QProxyStyle() { } virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const { flags |= Qt::TextWordWrap; QProxyStyle::drawItemText(painter, rect, flags, pal, enabled, text, textRole); } private: Q_DISABLE_COPY(QtPushButtonStyleProxy) };
And later in your own MyQtPushButton:
MyQtPushButton::MyQtPushButton() : QPushButton() { setStyle(new QtPushButtonStyleProxy()); }
See more about the QProxyStyle class in the Qt documentation.
source share