Двухцветный текст в QPushButton
Мне нужен QPushButton с двумя цветами в тексте. Я нашел решение с HTML-кодом в QTextDocument, и оно работает. Но мне нужно выравнивание по центру, и HTML-код не работает.
QTextDocument Text;
Text.setHtml("<p align=center><font>Button</font><br/><font color=yellow>1</font></p>");
QPixmap pixmap(Text.size().width(), Text.size().height());
pixmap.fill( Qt::transparent );
QPainter painter(&pixmap);
Text.drawContents(&painter, pixmap.rect());
QIcon ButtonIcon(pixmap);
ui->toolButton->setText("");
ui->toolButton->setIcon(ButtonIcon);
ui->toolButton->setIconSize(pixmap.rect().size());
И я получаю,
Тот же код HTML работает в QLabel
ui->label->setText("<p align=center><font>Label</font><br/><font color=yellow>1</font></p>");
Любое решение?
Спасибо большое.