【发布时间】:2015-10-18 11:38:17
【问题描述】:
我想在QToolButton 中使用HTML 格式。例如在这张图片中,我应该在“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 中使用了布局,但它显示为空框。
QVBoxLayout *titleLayout = new QVBoxLayout();
QLabel *nameLabel = new QLabel("Name");
QLabel *onlineLabel = new QLabel ("online");
titleLayout->addWidget(nameLabel);
titleLayout->addWidget(onlineLabel);
viewControl->setLayout(titleLayout);
【问题讨论】:
-
为什么你认为你可以在 QToolButton 中使用 html ?
-
我在 QLabel 中使用了 html,我想我可以在 QToolButton 中使用它。 @perencia
-
也许这会有所帮助:Link