我需要一个QPushButton,文本中有两种颜色.我在QTextDocument中找到了一个带有html代码的解决方案,它正在运行.但是我需要居中对齐并且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());
Run Code Online (Sandbox Code Playgroud)
我明白了, 
相同的代码HTML在QLabel中工作
ui->label->setText("<p align=center><font>Label</font><br/><font color=yellow>1</font></p>");
Run Code Online (Sandbox Code Playgroud)

有解决方案吗
非常感谢.
我正在使用一个可序列化的类来保存xml解析器结果,但是当我读到它在Android中非常慢时,我改为parcelable类.
现在,我想将内容parcelable类保存到文件中.
我该怎么做?
谢谢.问候.