Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt 5.6, how to draw text with a different fill and outline colours

I'm using Qt5.6, I am drawing text on a video window, however sometimes the text is not very readable due to the video content in the window. I'm current drawing the text on the painter context with the 'drawText' method. Whilst I can set the pen colour which controls the fill, I do not seem to be able to set an outline colour.

I would like to draw the text with a black outline to make it stand out. Unfortunately firewall where I am working makes life very difficult and any useful web-site that might help, seems to be blocked, hence this post.

Thank you,

like image 664
SPlatten Avatar asked Dec 08 '25 13:12

SPlatten


1 Answers

Try using QPainterPath::addText().

You can add the text to a path, then QPainter::fillPath() and QPainter::strokePath() the path.

Or you can direcly use QPainter::drawPath() with a brush and pen set.

like image 50
dtech Avatar answered Dec 11 '25 11:12

dtech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!