我想在QToolButton中使用超文本标记语言格式。例如,在这张图片中,我应该在"Sara“和"Online”中创建QToolButton。

下面是我的代码:
viewControl=new QToolButton(this);
QString labelText = "<P><b><i><FONT COLOR='#fff'>";
labelText .append("Sara");
labelText .append("</i></b></P></br>");
labelText .append("online");
viewControl->setText(labelText);但是QToolButton似乎不能定义超文本标记语言格式。

如何解决?
我在QToolButton中也使用了layout,但它显示了空框。
QVBoxLayout *titleLayout = new QVBoxLayout();
QLabel *nameLabel = new QLabel("Name");
QLabel *onlineLabel = new QLabel ("online");
titleLayout->addWidget(nameLabel);
titleLayout->addWidget(onlineLabel);
viewControl->setLayout(titleLayout);发布于 2015-10-18 20:14:52
根据前面提到的答案here
如果不对QToolButton进行子类化并覆盖paintEvent,我认为这是不可能的。但是你可以尝试这样做:
toolButton->setStyleSheet("font-weight: Italic");https://stackoverflow.com/questions/33197512
复制相似问题