As a workaround, you can use a shortcut or text document to print the text you want. You have to color it in pixmap and use pixmap on your button:
QPushButton *button = new QPushButton(this); QTextDocument Text; Text.setHtml("<h2><i>Hello</i> ""<font color=red>Qt!</font></h2>"); QPixmap pixmap(Text.size().width(), Text.size().height()); pixmap.fill( Qt::transparent ); QPainter painter( &pixmap ); Text.drawContents(&painter, pixmap.rect()); QIcon ButtonIcon(pixmap); button->setIcon(ButtonIcon); button->setIconSize(pixmap.rect().size());
You can also find the implementation of the button with extended text here .
Another option is to use the QxtPushButton class from libqxt. QxtPushButton widget is an advanced QPushButton with support for rotation and rich text.
source share