How to create a bold, red text label in Qt?

前端 未结 4 2092
甜味超标
甜味超标 2020-12-29 02:01

I want to write a single, bold red line in my application using Qt.

As far as I understand, I would create a QLabel, set its textFormat to rich text and give it a ri

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-29 02:15

    You can use Qt StyleSheets and set the styleSheet property of QLabel

    warning->setStyleSheet("font-weight: bold; color: red");
    

    Qt supports most CSS styles on its QWidget-derived classes. You don't need to set the text format to Qt::RichText for this to work.

提交回复
热议问题