0

I want to use HTML format in QToolButton. for example in this picture , I should create QToolButton in "Sara" and "Online".

enter image description here

Here is my code:

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);

But it seems QToolButton cannot define HTML format. enter image description here

How to resolve it?

I also used layout in QToolButton but it show me empty box.

QVBoxLayout *titleLayout = new QVBoxLayout();
QLabel *nameLabel = new QLabel("Name");
QLabel *onlineLabel = new QLabel ("online");
titleLayout->addWidget(nameLabel);
titleLayout->addWidget(onlineLabel);
viewControl->setLayout(titleLayout);
demonplus
  • 5,613
  • 12
  • 49
  • 68
Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81

1 Answers1

1

According to the answer mentioned here

I don't think this is possible without subclassing QToolButton and overriding the paintEvent. but you can try something like this:

toolButton->setStyleSheet("font-weight: Italic");
Community
  • 1
  • 1
vishal
  • 2,258
  • 1
  • 18
  • 27