PDA

View Full Version : QStaticText and Style Sheets



Momergil
25th August 2014, 21:24
Hello!

Is there a possibility to use Style Sheets alongside QStaticText? Or I'ld have to use QLabel to draw text if I want to take advantage of the Style Sheet system?


Thanks,

Momergil

d_stranz
26th August 2014, 03:18
QStaticText is not derived from QObject or QWidget; it is just a container for formatted text that will be drawn by QPainter. So it doesn't support style sheets (which are applied to QWidget classes), but it does support formatted text such as Rich Text.

If you need to use style sheets, then I think you are stuck with QLabel. On the other hand, if you are manually drawing text using QPainter, then you can use QStaticText.

It would be really nice if there was a style sheet to Rich Text format converter, but I don't think there is any such thing, at least not in the documented part of Qt.