简体   繁体   中英

How to set window title with a colored string in Qt?

How to set window title with a colored string in Qt? And how to set window title with a partly colored string in Qt? For example

My Office [red]

My Office [black] - my.doc [red]

How to set window title with a colored string in Qt? And how to set window title with a partly colored string in Qt?

You cannot control that from Qt as it is not Qt drawing them in the end. However, you can use QPainter with the following methods to draw a custom title bar line on top of your widget:

void QPainter::setPen(const QColor & color)

void QPainter::setBrush(const QBrush & brush)

void QPainter::drawLine(const QLine & line)

You could check out the analog clock example in Qt for painting customization.

Do not forget about the Qt::FramelessWindowHint flag either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM