Two colours text in QPushButton

As s workaround you can use a label or text document to print the text you want. You should paint it to a pixmap and use the 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 … Read more

Qt5 – setting background color to QPushButton and QCheckBox

I had the same issue, but finally got this to work. I’m using Qt 5 with the Fusion color theme: QPalette pal = button->palette(); pal.setColor(QPalette::Button, QColor(Qt::blue)); button->setAutoFillBackground(true); button->setPalette(pal); button->update(); Try these commands in the exact order as above, and if that still doesn’t work, set your theme to Fusion and try again. Good luck!